getFirstActivePaymentMethodId example

array $currencies = null,
        ?array $languages = null,
        ?array $shippingMethods = null,
        ?array $paymentMethods = null,
        ?array $countries = null,
        array $overwrites = []
    ): string {
        $context = Context::createDefaultContext();

        $languageId ??= Defaults::LANGUAGE_SYSTEM;
        $currencyId ??= Defaults::CURRENCY;
        $paymentMethodId ??= $this->getFirstActivePaymentMethodId();
        $shippingMethodId ??= $this->getFirstActiveShippingMethodId();
        $countryId ??= $this->getFirstActiveCountryId();

        $currencies = $this->formatToMany($currencies$currencyId, 'currency', $context);
        $languages = $this->formatToMany($languages$languageId, 'language', $context);
        $shippingMethods = $this->formatToMany($shippingMethods$shippingMethodId, 'shipping_method', $context);
        $paymentMethods = $this->formatToMany($paymentMethods$paymentMethodId, 'payment_method', $context);
        $countries = $this->formatToMany($countries$countryId, 'country', $context);

        $data = [
            'id' => $id,
            
$this->createSalesChannel($newSalesChannelId$shop$connection);
        $this->createSalesChannelDomain($newSalesChannelId$shop$connection);
    }

    /** * @param Shop $shop */
    private function createSalesChannel(string $newId, array $shop, Connection $connection): void
    {
        $typeId = Defaults::SALES_CHANNEL_TYPE_STOREFRONT;

        $paymentMethod = $this->getFirstActivePaymentMethodId($connection);
        $shippingMethod = $this->getFirstActiveShippingMethodId($connection);

        $languageId = $this->getLanguageId($shop['locale']$connection);

        $currencyId = $this->getCurrencyId($shop['currency']$connection);

        $countryId = $this->getCountryId($shop['country']$connection);

        $statement = $connection->prepare(
            'INSERT INTO sales_channel ( id, type_id, access_key, navigation_category_id, navigation_category_version_id, language_id, currency_id, payment_method_id, shipping_method_id, country_id, customer_group_id, created_at ) VALUES ( ?, UNHEX(?), ?, ?, UNHEX(?), ?, ?, ?, ?, ?, ?, ? )'
Home | Imprint | This part of the site doesn't use cookies.