@param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet

@return string|null
964517
protected function getIso2Code(DataSetInterface $dataSet)
    {
        if (isset($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE]) && !empty($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE])) {
            return $dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_2_CODE];
        }

        return null;
    }
1228242
public function execute(DataSetInterface $dataSet): void
    {
        $customerReference = $dataSet[CartDataSetInterface::CUSTOMER_REFERENCE];
        if (!isset($this->customerReferenceCache[$customerReference])) {
            $customerQuery = SpyCustomerQuery::create();
            $idCustomer = $customerQuery
                ->select(SpyCustomerTableMap::COL_ID_CUSTOMER)
                ->findOneByCustomerReference($customerReference);

            if (!$idCustomer) {
                throw new EntityNotFoundException(sprintf('Could not find customer by reference "%s"', $customerReference));
            }

            $this->customerReferenceCache[$customerReference] = $idCustomer;
        }
    }
1154815
protected function saveProductMeasurementSalesUnitStore(DataSetInterface $dataSet): void
    {
        SpyProductMeasurementSalesUnitStoreQuery::create()
            ->filterByFkProductMeasurementSalesUnit($this->getIdProductMeasurementSalesUnitByKey($dataSet[ProductMeasurementSalesUnitStoreDataSet::COLUMN_SALES_UNIT_KEY]))
            ->filterByFkStore($this->getIdStoreByName($dataSet[ProductMeasurementSalesUnitStoreDataSet::COLUMN_STORE_NAME]))
            ->findOneOrCreate()
            ->save();
    }
1311559
public function execute(DataSetInterface $dataSet): void
    {
        $productSku = $dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_CONCRETE_SKU];

        if (!isset($this->idProductCache[$productSku])) {
            $productEntity = SpyProductQuery::create()->findOneBySku($productSku);
            if (!$productEntity) {
                throw new EntityNotFoundException(sprintf('Could not find product by sku "%s"', $productSku));
            }

            $this->idProductCache[$productSku] = $productEntity->getIdProduct();
        }

        $dataSet[ProductAlternativeDataSetInterface::FK_PRODUCT] = $this->idProductCache[$productSku];
    }
949010
protected function normalizeAmount(DataSetInterface $dataSet): DataSetInterface
    {
        $isVariable = $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_IS_VARIABLE];
        $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_IS_VARIABLE] = $isVariable;

        $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_DEFAULT_AMOUNT] = (int)$dataSet[ProductPackagingUnitDataSetInterface::COLUMN_DEFAULT_AMOUNT];
        $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MIN] = (int)$dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MIN];
        $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MAX] = (int)$dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MAX];
        $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL] = (int)$dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL];

        if ($isVariable && $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL] === 0) {
            $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL] = 1;
        }

        if ($isVariable && $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MIN] === 0) {
            $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MIN] = $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL];
        }

        if (!$isVariable) {
            $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MIN] = null;
            $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_MAX] = null;
            $dataSet[ProductPackagingUnitDataSetInterface::COLUMN_AMOUNT_INTERVAL] = null;
        }

        return $dataSet;
    }
1344262
public function execute(DataSetInterface $dataSet)
    {
        $productDiscontinuedEntity = SpyProductDiscontinuedQuery::create()
            ->filterByFkProduct($dataSet[ProductDiscontinuedDataSetInterface::ID_PRODUCT])
            ->findOneOrCreate();

        $productDiscontinuedEntity->setActiveUntil($this->getActiveUntilDate());

        $productDiscontinuedEntity->save();

        $this->saveLocalizedNotes($productDiscontinuedEntity, $dataSet);

        $this->addPublishEvents(
            ProductDiscontinuedEvents::PRODUCT_DISCONTINUED_PUBLISH,
            $productDiscontinuedEntity->getIdProductDiscontinued()
        );
    }
903921
protected function getLanguageIdentifier($idLocale, DataSetInterface $dataSet)
    {
        foreach ($dataSet[AddLocalesStep::KEY_LOCALES] as $localeName => $localeId) {
            if ($idLocale === $localeId) {
                return mb_substr($localeName, 0, 2);
            }
        }

        throw new Exception(sprintf('Could not extract language identifier for idLocale "%s"', $idLocale));
    }
1306808
protected function getCategoryTemplate(DataSetInterface $dataSet): SpyCategoryTemplate
    {
        $categoryTemplateEntity = SpyCategoryTemplateQuery::create()->findOneByName($dataSet[static::KEY_TEMPLATE_NAME]);
        if (!$categoryTemplateEntity) {
            throw new CategoryTemplateNotFoundException(sprintf('CategoryTemplate with template name "%s" not found!', $dataSet[static::KEY_TEMPLATE_NAME]));
        }

        return $categoryTemplateEntity;
    }
1299570
protected function validateDataSet(DataSetInterface $dataSet): void
    {
        if (!$dataSet[MerchantDataSetInterface::MERCHANT_KEY]) {
            throw new InvalidDataException('"' . MerchantDataSetInterface::MERCHANT_KEY . '" is required.');
        }

        if (!$dataSet[MerchantDataSetInterface::NAME]) {
            throw new InvalidDataException('"' . MerchantDataSetInterface::NAME . '" is required.');
        }
    }
690282
public function execute(DataSetInterface $dataSet)
    {
        $this->preparePriceDataKeysCache($dataSet);
        $priceData = $this->getPriceData($dataSet);
        if ($priceData === null) {
            $dataSet[PriceProductDataSet::KEY_PRICE_DATA] = null;
            $dataSet[PriceProductDataSet::KEY_PRICE_DATA_CHECKSUM] = null;

            return;
        }
        $dataSet[PriceProductDataSet::KEY_PRICE_DATA] = $this->utilEncodingService->encodeJson($priceData);
        $dataSet[PriceProductDataSet::KEY_PRICE_DATA_CHECKSUM] = $this->priceProductFacade
            ->generatePriceDataChecksum($priceData);
    }
908813
protected function findExistingPriceProductStoreEntity(DataSetInterface $dataSet): ?SpyPriceProductMerchantRelationship
    {
        $query = SpyPriceProductMerchantRelationshipQuery::create()
            ->usePriceProductStoreQuery()
                ->filterByFkStore($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_STORE])
                ->filterByFkCurrency($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_CURRENCY])
                ->filterByFkPriceProduct($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRICE_PRODUCT])
            ->endUse()
            ->filterByFkMerchantRelationship($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_MERCHANT_RELATIONSHIP]);

        if (!empty($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_ABSTRACT])) {
            $query->filterByFkProductAbstract($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_ABSTRACT]);
        } else {
            $query->filterByFkProduct($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_CONCRETE]);
        }

        return $query->findOne();
    }
332600
public function execute(DataSetInterface $dataSet): void
    {
        if (!$dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_ABSTRACT_SKU]) {
            return;
        }

        $this->addAlternativeProductAbstractId($dataSet);
    }
119505
public function execute(DataSetInterface $dataSet)
    {
        $quoteEntity = SpyQuoteQuery::create()
            ->filterByKey($dataSet[CartDataSetInterface::KEY_CART])
            ->findOneOrCreate();

        $quoteEntity->fromArray($dataSet->getArrayCopy());
        $quoteEntity
            ->setFkStore($dataSet[CartDataSetInterface::ID_STORE]);

        $quoteEntity->save();
    }
1170022
public function execute(DataSetInterface $dataSet): void
    {
        $dataSet = $this->filterDataSet($dataSet);

        $spyProductMeasurementSalesUnitEntity = $this->saveProductMeasurementSalesUnit($dataSet);

        $this->addPublishEvents(
            static::PRODUCT_CONCRETE_MEASUREMENT_UNIT_PUBLISH,
            $spyProductMeasurementSalesUnitEntity->getFkProduct()
        );
    }
8213
public function execute(DataSetInterface $dataSet): void
    {
        $merchantRelationshipKey = $dataSet[MerchantRelationshipProductListDataSetInterface::MERCHANT_RELATION_KEY];
        if (!$merchantRelationshipKey) {
            throw new InvalidDataException(sprintf('"%s" is required.', MerchantRelationshipProductListDataSetInterface::MERCHANT_RELATION_KEY));
        }

        if (!isset($this->idMerchantRelationshipCache[$merchantRelationshipKey])) {
            /** @var \Orm\Zed\MerchantRelationship\Persistence\SpyMerchantRelationshipQuery $merchantRelationshipQuery */
            $merchantRelationshipQuery = SpyMerchantRelationshipQuery::create()->select(SpyMerchantRelationshipTableMap::COL_ID_MERCHANT_RELATIONSHIP);
            /** @var int|null $idMerchantRelationship */
            $idMerchantRelationship = $merchantRelationshipQuery->findOneByMerchantRelationshipKey($merchantRelationshipKey);

            if (!$idMerchantRelationship) {
                throw new EntityNotFoundException(sprintf('Could not find Merchant Relationship by key "%s"', $merchantRelationshipKey));
            }
            $this->idMerchantRelationshipCache[$merchantRelationshipKey] = $idMerchantRelationship;
        }
        $dataSet[MerchantRelationshipProductListDataSetInterface::ID_MERCHANT_RELATIONSHIP] = $this->idMerchantRelationshipCache[$merchantRelationshipKey];
    }
472720
public function execute(DataSetInterface $dataSet): void
    {
        $storeTransfer = $this->getStoreByName($dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_STORE]);
        $currencyTransfer = $this->getCurrencyByCode($dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_CURRENCY]);
        $merchantRelationshipTransfer = $this->getMerchantRelationshipByKey(
            $dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_MERCHANT_RELATIONSHIP_KEY]
        );

        if ($dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_SALES_ORDER_THRESHOLD_TYPE_KEY] && $dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_THRESHOLD]) {
            $merchantRelationshipSalesOrderThresholdTransfer = $this->createMerchantRelationshipSalesOrderThresholdTransfer(
                $dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_SALES_ORDER_THRESHOLD_TYPE_KEY],
                $merchantRelationshipTransfer,
                $storeTransfer,
                $currencyTransfer,
                (int)$dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_THRESHOLD],
                (int)$dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_FEE],
                $dataSet[MerchantRelationshipSalesOrderThresholdDataSetInterface::COLUMN_MESSAGE_GLOSSARY_KEY]
            );

            $this->merchantRelationshipSalesOrderThresholdFacade->saveMerchantRelationshipSalesOrderThreshold(
                $merchantRelationshipSalesOrderThresholdTransfer
            );
        }
    }
1180685
public function execute(DataSetInterface $dataSet): void
    {
        $currencyCode = $dataSet[PriceProductDataSet::KEY_CURRENCY];
        if (!isset($this->idCurrencyCache[$currencyCode])) {
            $currencyQuery = new SpyCurrencyQuery();
            $idCurrency = $currencyQuery
                ->select(SpyCurrencyTableMap::COL_ID_CURRENCY)
                ->findOneByCode($currencyCode);

            if (!$idCurrency) {
                throw new EntityNotFoundException(sprintf('Could not find currency by code "%s"', $currencyCode));
            }

            $this->idCurrencyCache[$currencyCode] = $idCurrency;
        }

        $dataSet[PriceProductDataSet::ID_CURRENCY] = $this->idCurrencyCache[$currencyCode];
    }