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

@return \Orm\Zed\Category\Persistence\SpyCategory
329959
protected function findOrCreateCategory(DataSetInterface $dataSet)
    {
        $categoryEntity = SpyCategoryQuery::create()
            ->filterByCategoryKey($dataSet[static::KEY_CATEGORY_KEY])
            ->findOneOrCreate();

        $categoryEntity->fromArray($dataSet->getArrayCopy());

        if (!empty($dataSet[static::KEY_TEMPLATE_NAME])) {
            $categoryTemplateEntity = $this->getCategoryTemplate($dataSet);
            $categoryEntity->setFkCategoryTemplate($categoryTemplateEntity->getIdCategoryTemplate());
        }

        if ($categoryEntity->isNew() || $categoryEntity->isModified()) {
            $categoryEntity->save();
        }

        return $categoryEntity;
    }
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();
    }
264755
protected function saveProductListCategory(DataSetInterface $dataSet): void
    {
        $productListCategoryEntity = SpyProductListCategoryQuery::create()
            ->filterByFkProductList($dataSet[ProductListDataSetInterface::ID_PRODUCT_LIST])
            ->filterByFkCategory($dataSet[ProductListDataSetInterface::ID_CATEGORY])
            ->findOneOrCreate();

        $productListCategoryEntity->setFkProductList($dataSet[ProductListDataSetInterface::ID_PRODUCT_LIST])
            ->setFkCategory($dataSet[ProductListDataSetInterface::ID_CATEGORY])
            ->save();

        $this->addPublishEvents(
            ProductListEvents::PRODUCT_LIST_CATEGORY_PUBLISH,
            $productListCategoryEntity->getFkCategory()
        );
    }
442274
protected function getIso3Code(DataSetInterface $dataSet)
    {
        if (isset($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_3_CODE]) && !empty($dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_3_CODE])) {
            return $dataSet[CompanyUnitAddressDataSet::COUNTRY_ISO_3_CODE];
        }

        return null;
    }
74891
protected function saveProductMeasurementUnit(DataSetInterface $dataSet): SpyProductMeasurementUnit
    {
        $productMeasurementUnitEntity = SpyProductMeasurementUnitQuery::create()
            ->filterByCode($dataSet[ProductMeasurementUnitDataSet::COLUMN_CODE])
            ->findOneOrCreate();

        $productMeasurementUnitEntity
            ->setName($dataSet[ProductMeasurementUnitDataSet::COLUMN_NAME])
            ->setDefaultPrecision($this->filterDefaultPrecision($dataSet[ProductMeasurementUnitDataSet::COLUMN_DEFAULT_PRECISION]))
            ->save();
        return $productMeasurementUnitEntity;
    }
940131
protected function checkIfProductHasConcreteOrAbstractAlternative(DataSetInterface $dataSet): void
    {
        if (!$dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_CONCRETE_SKU] &&
            !$dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_ABSTRACT_SKU]
        ) {
            throw new InvalidDataException(
                sprintf(
                    'Product concrete with SKU "%s" has neither concrete nor abstract alternative products',
                    $dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_CONCRETE_SKU]
                )
            );
        }
    }
284653
public function execute(DataSetInterface $dataSet): void
    {
        $companyBusinessUnitKey = $dataSet[MerchantRelationshipDataSetInterface::COMPANY_BUSINESS_UNIT_OWNER_KEY];
        if (!$companyBusinessUnitKey) {
            throw new InvalidDataException('"' . MerchantRelationshipDataSetInterface::COMPANY_BUSINESS_UNIT_OWNER_KEY . '" is required.');
        }

        if (!isset($this->idCompanyBusinessUnitCache[$companyBusinessUnitKey])) {
            $idCompanyBusinessUnit = SpyCompanyBusinessUnitQuery::create()
                ->select(SpyCompanyBusinessUnitTableMap::COL_ID_COMPANY_BUSINESS_UNIT)
                ->findOneByKey($companyBusinessUnitKey);

            if (!$idCompanyBusinessUnit) {
                throw new EntityNotFoundException(sprintf('Could not find Company Business Unit by key "%s"', $companyBusinessUnitKey));
            }

            $this->idCompanyBusinessUnitCache[$companyBusinessUnitKey] = $idCompanyBusinessUnit;
        }

        $dataSet[MerchantRelationshipDataSetInterface::ID_COMPANY_BUSINESS_UNIT] = $this->idCompanyBusinessUnitCache[$companyBusinessUnitKey];
    }
219237
protected function bindDataset($dataset)
    {
        $datasetClass = $this->datasetClass;
        $object = new $datasetClass();

        if ($object instanceof DataSetInterface) {
            return $object->bind($dataset);
        }

        if ($dataset instanceof \Traversable) {
            $dataset = iterator_to_array($dataset);
        } elseif (is_object($dataset)) {
            $dataset = [$dataset];
        } elseif (!is_array($dataset)) {
            throw new \InvalidArgumentException(sprintf('Need an array or object in %s::%s()', __CLASS__, __METHOD__));
        }

        foreach ($dataset as $data) {
            $object[] = $data;
        }

        return $object;
    }
1295448
public function execute(DataSetInterface $dataSet): void
    {
        $merchantRelationshipEntity = SpyMerchantRelationshipQuery::create()
            ->filterByMerchantRelationshipKey($dataSet[MerchantRelationshipDataSetInterface::MERCHANT_RELATIONSHIP_KEY])
            ->findOneOrCreate();

        $merchantRelationshipEntity
            ->setFkMerchant($dataSet[MerchantRelationshipDataSetInterface::ID_MERCHANT])
            ->setFkCompanyBusinessUnit($dataSet[MerchantRelationshipDataSetInterface::ID_COMPANY_BUSINESS_UNIT])
            ->save();

        $this->saveMerchantRelationshipToCompanyBusinessUnit($dataSet, $merchantRelationshipEntity->getPrimaryKey());
    }
1026433
public function execute(DataSetInterface $dataSet): void
    {
        $shoppingListCompanyUserEntity = $this->createShoppingListCompanyUserQuery()
            ->filterByFkShoppingList($dataSet[ShoppingListCompanyUserDataSetInterface::ID_SHOPPING_LIST])
            ->filterByFkCompanyUser($dataSet[ShoppingListCompanyUserDataSetInterface::ID_COMPANY_USER])
            ->findOneOrCreate();

        $shoppingListCompanyUserEntity
            ->setFkShoppingListPermissionGroup($dataSet[ShoppingListCompanyUserDataSetInterface::ID_PERMISSION_GROUP])
            ->save();
    }
1166868
public function execute(DataSetInterface $dataSet)
    {
        $companyUnitAddressLabelEntity = SpyCompanyUnitAddressLabelQuery::create()
            ->filterByName($dataSet[CompanyUnitAddressLabelDataSet::LABEL_NAME])
            ->findOneOrCreate();

        $companyUnitAddressLabelEntity->save();
    }
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()
        );
    }
65839
public function execute(DataSetInterface $dataSet): void
    {
        $productListKey = $dataSet[ProductListDataSetInterface::PRODUCT_LIST_KEY];
        if (!$productListKey) {
            throw new InvalidDataException(sprintf('"%s" is required.', ProductListDataSetInterface::PRODUCT_LIST_KEY));
        }

        $dataSet[ProductListDataSetInterface::ID_PRODUCT_LIST] = $this->getIdProductListByKey($productListKey);
    }
190712
public function execute(DataSetInterface $dataSet): void
    {
        $companyBusinessUnitKey = $dataSet[CompanyBusinessUnitDataSet::PARENT_BUSINESS_UNIT_KEY];
        if (!$companyBusinessUnitKey) {
            return;
        }

        $dataSet[CompanyBusinessUnitDataSet::FK_PARENT_BUSINESS_UNIT] = $this->businessUnitDataImportRepository
            ->getIdCompanyBusinessUnitByKey($companyBusinessUnitKey);
    }
332600
public function execute(DataSetInterface $dataSet): void
    {
        if (!$dataSet[ProductAlternativeDataSetInterface::KEY_COLUMN_ALTERNATIVE_PRODUCT_ABSTRACT_SKU]) {
            return;
        }

        $this->addAlternativeProductAbstractId($dataSet);
    }
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.');
        }
    }
598519
protected function saveProductMeasurementSalesUnit(DataSetInterface $dataSet): SpyProductMeasurementSalesUnit
    {
        $productMeasurementSalesUnitEntity = $this->getProductBySku($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_CONCRETE_SKU]);
        $productMeasurementBaseUnitEntity = $this->getProductMeasurementBaseUnit($productMeasurementSalesUnitEntity->getFkProductAbstract());

        $spyProductMeasurementSalesUnitEntity = SpyProductMeasurementSalesUnitQuery::create()
            ->filterByKey($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_SALES_UNIT_KEY])
            ->findOneOrCreate();

        $spyProductMeasurementSalesUnitEntity
            ->setFkProductMeasurementBaseUnit($productMeasurementBaseUnitEntity->getIdProductMeasurementBaseUnit())
            ->setFkProduct($productMeasurementSalesUnitEntity->getIdProduct())
            ->setFkProductMeasurementUnit($this->getProductMeasurementUnitIdByCode($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_CODE]))
            ->setConversion($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_CONVERSION])
            ->setPrecision($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_PRECISION])
            ->setIsDefault($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_IS_DEFAULT])
            ->setIsDisplayed($dataSet[ProductMeasurementSalesUnitDataSet::COLUMN_IS_DISPLAYED])
            ->save();

        return $spyProductMeasurementSalesUnitEntity;
    }