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

@throws \Spryker\Zed\DataImport\Business\Exception\InvalidDataException
@throws \Spryker\Zed\DataImport\Business\Exception\EntityNotFoundException

@return void
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];
    }
1023594
public function execute(DataSetInterface $dataSet)
    {
        $mimeTypeEntity = SpyMimeTypeQuery::create()
            ->filterByName($dataSet[MimeTypeDataSetInterface::KEY_NAME])
            ->findOneOrCreate();

        $mimeTypeEntity->setIsAllowed($dataSet[MimeTypeDataSetInterface::KEY_IS_ALLOWED]);
        $mimeTypeEntity->save();
    }
628397
public function execute(DataSetInterface $dataSet): void
    {
        $this->validateDataSet($dataSet);

        $merchantEntity = SpyMerchantQuery::create()
            ->filterByMerchantKey($dataSet[MerchantDataSetInterface::MERCHANT_KEY])
            ->findOneOrCreate();

        $merchantEntity
            ->setName($dataSet[MerchantDataSetInterface::NAME])
            ->save();
    }
174041
public function execute(DataSetInterface $dataSet)
    {
        $companyKey = $dataSet[CompanyUnitAddressDataSet::COMPANY_KEY];
        if (!isset($this->idCompanyCache[$companyKey])) {
            $companyQuery = new SpyCompanyQuery();
            $idCompany = $companyQuery
                ->select(SpyCompanyTableMap::COL_ID_COMPANY)
                ->findOneByKey($companyKey);

            if (!$idCompany) {
                throw new EntityNotFoundException(sprintf('Could not find company by key "%s"', $companyKey));
            }

            $this->idCompanyCache[$companyKey] = $idCompany;
        }

        $dataSet[CompanyUnitAddressDataSet::ID_COMPANY] = $this->idCompanyCache[$companyKey];
    }
141583
public function execute(DataSetInterface $dataSet): void
    {
        if (!$dataSet[MerchantRelationshipDataSetInterface::COMPANY_BUSINESS_UNIT_ASSIGNEE_KEYS]) {
            $dataSet[MerchantRelationshipDataSetInterface::ID_COMPANY_BUSINESS_UNIT_ASSIGNEE_COLLECTION] = [];

            return;
        }

        $companyBusinessUnitKeys = explode(
            $this->getAssigneeDelimiter(),
            $dataSet[MerchantRelationshipDataSetInterface::COMPANY_BUSINESS_UNIT_ASSIGNEE_KEYS]
        );

        $companyBusinessUnitAssignee = [];
        foreach ($companyBusinessUnitKeys as $companyBusinessUnitKey) {
            $companyBusinessUnitAssignee[] = $this->findIdCompanyBusinessUnit($companyBusinessUnitKey);
        }

        $dataSet[MerchantRelationshipDataSetInterface::ID_COMPANY_BUSINESS_UNIT_ASSIGNEE_COLLECTION] = $companyBusinessUnitAssignee;
    }
1147232
protected function filterDataSet(DataSetInterface $dataSet): DataSetInterface
    {
        if ($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_CONVERSION] === "") {
            $dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_CONVERSION] = null;
        }

        if ($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_PRECISION] === "") {
            $dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_PRECISION] = null;
        }

        return $dataSet;
    }
1049138
public function execute(DataSetInterface $dataSet): void
    {
        $productAbstractSku = $dataSet[PriceProductDataSet::KEY_ABSTRACT_SKU];
        if (empty($productAbstractSku)) {
            return;
        }

        if (!isset($this->idProductAbstractCache[$productAbstractSku])) {
            $productQuery = new SpyProductAbstractQuery();
            $idProduct = $productQuery
                ->select(SpyProductAbstractTableMap::COL_ID_PRODUCT_ABSTRACT)
                ->findOneBySku($productAbstractSku);

            if (!$idProduct) {
                throw new EntityNotFoundException(sprintf('Could not find abstract product by sku "%s"', $productAbstractSku));
            }

            $this->idProductAbstractCache[$productAbstractSku] = $idProduct;
        }

        $dataSet[PriceProductDataSet::ID_PRODUCT_ABSTRACT] = $this->idProductAbstractCache[$productAbstractSku];
    }
290383
public function execute(DataSetInterface $dataSet): void
    {
        $companyUserKey = $dataSet[ShoppingListCompanyUserDataSetInterface::COLUMN_COMPANY_USER_KEY];
        if (!isset($this->idCompanyUserCache[$companyUserKey])) {
            $companyUserQuery = new SpyCompanyUserQuery();
            $idCompanyUser = $companyUserQuery
                ->select([SpyCompanyUserTableMap::COL_ID_COMPANY_USER])
                ->findOneByKey($companyUserKey);

            if (!$idCompanyUser) {
                throw new EntityNotFoundException(sprintf('Could not find company user by key "%s"', $companyUserKey));
            }

            $this->idCompanyUserCache[$companyUserKey] = $idCompanyUser;
        }

        $dataSet[ShoppingListCompanyUserDataSetInterface::ID_COMPANY_USER] = $this->idCompanyUserCache[$companyUserKey];
    }
898756
public function execute(DataSetInterface $dataSet): void
    {
        $dataSet[CompanyBusinessUnitDataSet::ID_COMPANY] = $this->getIdCompanyByKey($dataSet[CompanyBusinessUnitDataSet::COMPANY_KEY]);
    }
718008
protected function saveMerchantRelationshipToCompanyBusinessUnit(DataSetInterface $dataSet, int $idMerchantRelationship): void
    {
        SpyMerchantRelationshipToCompanyBusinessUnitQuery::create()
            ->filterByFkMerchantRelationship($idMerchantRelationship)
            ->delete();

        foreach ($dataSet[MerchantRelationshipDataSetInterface::ID_COMPANY_BUSINESS_UNIT_ASSIGNEE_COLLECTION] as $idCompanyBusinessUnit) {
            (new SpyMerchantRelationshipToCompanyBusinessUnit())
                ->setFkMerchantRelationship($idMerchantRelationship)
                ->setFkCompanyBusinessUnit($idCompanyBusinessUnit)
                ->save();
        }
    }
40553
public function train(Dataset $dataset) : void
    {
        if (!$dataset instanceof Labeled) {
            throw new InvalidArgumentException('This estimator requires a'
                . ' labeled training set.');
        }

        $this->network = new FeedForward(
            new Placeholder1D($dataset->numColumns()),
            [],
            new Continuous($this->alpha, $this->costFn),
            $this->optimizer
        );

        $this->steps = [];

        $this->partial($dataset);
    }
424406
public function execute(DataSetInterface $dataSet)
    {
        $labelName = $dataSet[CompanyUnitAddressLabelRelationDataSet::LABEL_NAME];
        if (!isset($this->idCompanyUnitAddressLabelCache[$labelName])) {
            $companyUnitAddressLabelQuery = new SpyCompanyUnitAddressLabelQuery();
            $idCompanyUnitAddressLabel = $companyUnitAddressLabelQuery
                ->select(SpyCompanyUnitAddressLabelTableMap::COL_ID_COMPANY_UNIT_ADDRESS_LABEL)
                ->findOneByName($labelName);

            if (!$idCompanyUnitAddressLabel) {
                throw new CompanyUnitAddressLabelNotFoundException(sprintf('Could not find CompanyUnitAddressLabel with name "%s".', $labelName));
            }

            $this->idCompanyUnitAddressLabelCache[$labelName] = $idCompanyUnitAddressLabel;
        }

        $dataSet[CompanyUnitAddressLabelRelationDataSet::ID_COMPANY_UNIT_ADDRESS_LABEL] = $this->idCompanyUnitAddressLabelCache[$labelName];
    }
1334506
public function train(Dataset $dataset) : void
    {
        if (!$dataset instanceof Labeled) {
            throw new InvalidArgumentException('This estimator requires a'
                . ' labeled training set.');
        }

        DatasetIsCompatibleWithEstimator::check($dataset, $this);

        $k = $dataset->numColumns();

        $this->columns = range(0, $dataset->numColumns() - 1);
        $this->maxFeatures = $this->maxFeatures ?? (int) round(sqrt($k));

        $this->grow($dataset);

        $this->columns = [];
    }
286412
public function execute(DataSetInterface $dataSet): void
    {
        $priceProductMerchantRelationshipEntity = $this->findExistingPriceProductStoreEntity($dataSet);

        $idPriceProductStore = $dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRICE_PRODUCT_STORE];
        if ($priceProductMerchantRelationshipEntity
            && $priceProductMerchantRelationshipEntity->getFkPriceProductStore() === $idPriceProductStore) {
            return;
        }

        if (!$priceProductMerchantRelationshipEntity) {
            $priceProductMerchantRelationshipEntity = (new SpyPriceProductMerchantRelationship())
                ->setFkMerchantRelationship($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_MERCHANT_RELATIONSHIP]);

            if (!empty($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_ABSTRACT])) {
                $priceProductMerchantRelationshipEntity->setFkProductAbstract($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_ABSTRACT]);
            } else {
                $priceProductMerchantRelationshipEntity->setFkProduct($dataSet[PriceProductMerchantRelationshipDataSetInterface::ID_PRODUCT_CONCRETE]);
            }
        }

        $priceProductMerchantRelationshipEntity->setFkPriceProductStore($idPriceProductStore);

        $eventName = $priceProductMerchantRelationshipEntity->isNew()
            ? PriceProductMerchantRelationshipDataImportConstants::ENTITY_SPY_PRICE_PRODUCT_MERCHANT_RELATIONSHIP_CREATE
            : PriceProductMerchantRelationshipDataImportConstants::ENTITY_SPY_PRICE_PRODUCT_MERCHANT_RELATIONSHIP_UPDATE;

        $priceProductMerchantRelationshipEntity->save();

        $this->addPublishEvents(
            $eventName,
            (int)$priceProductMerchantRelationshipEntity->getPrimaryKey()
        );
    }
859036
public function execute(DataSetInterface $dataSet): void
    {
        $productAlternativeQuery = SpyProductAlternativeQuery::create()
            ->filterByFkProduct($dataSet[ProductAlternativeDataSetInterface::FK_PRODUCT]);

        if ($dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_CONCRETE_SKU]) {
            $this->saveConcreteAlternative($dataSet, $productAlternativeQuery);
        }

        if ($dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_ABSTRACT_SKU]) {
            $this->saveAbstractAlternative($dataSet, $productAlternativeQuery);
        }
    }
1222559
public function execute(DataSetInterface $dataSet): void
    {
        $productMeasurementUnitEntity = $this->saveProductMeasurementUnit($dataSet);

        $this->addPublishEvents(
            static::PRODUCT_MEASUREMENT_UNIT_PUBLISH,
            $productMeasurementUnitEntity->getIdProductMeasurementUnit()
        );
    }
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();
    }