| Total Complexity | 157 | 
| Total Lines | 1751 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
Complex classes like DataImportBusinessFactory often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DataImportBusinessFactory, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 138 | class DataImportBusinessFactory extends SprykerDataImportBusinessFactory | ||
| 139 | { | ||
| 140 | /** | ||
| 141 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 142 | * | ||
| 143 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|null | ||
| 144 | */ | ||
| 145 | public function getDataImporterByType(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): ?DataImporterInterface | ||
| 146 |     { | ||
| 147 |         switch ($dataImportConfigurationActionTransfer->getDataEntity()) { | ||
| 148 | case DataImportConfig::IMPORT_TYPE_CURRENCY: | ||
| 149 | return $this->createCurrencyImporter($dataImportConfigurationActionTransfer); | ||
| 150 | case DataImportConfig::IMPORT_TYPE_CATEGORY_TEMPLATE: | ||
| 151 | return $this->createCategoryTemplateImporter($dataImportConfigurationActionTransfer); | ||
| 152 | case DataImportConfig::IMPORT_TYPE_CUSTOMER: | ||
| 153 | return $this->createCustomerImporter($dataImportConfigurationActionTransfer); | ||
| 154 | case DataImportConfig::IMPORT_TYPE_GLOSSARY: | ||
| 155 | return $this->createGlossaryImporter($dataImportConfigurationActionTransfer); | ||
| 156 | case DataImportConfig::IMPORT_TYPE_TAX: | ||
| 157 | return $this->createTaxImporter($dataImportConfigurationActionTransfer); | ||
| 158 | case DataImportConfig::IMPORT_TYPE_DISCOUNT: | ||
| 159 | return $this->createDiscountImporter($dataImportConfigurationActionTransfer); | ||
| 160 | case DataImportConfig::IMPORT_TYPE_DISCOUNT_STORE: | ||
| 161 | return $this->createDiscountStoreImporter($dataImportConfigurationActionTransfer); | ||
| 162 | case DataImportConfig::IMPORT_TYPE_DISCOUNT_VOUCHER: | ||
| 163 | return $this->createDiscountVoucherImporter($dataImportConfigurationActionTransfer); | ||
| 164 | case DataImportConfig::IMPORT_TYPE_PRODUCT_ATTRIBUTE_KEY: | ||
| 165 | return $this->createProductAttributeKeyImporter($dataImportConfigurationActionTransfer); | ||
| 166 | case DataImportConfig::IMPORT_TYPE_PRODUCT_MANAGEMENT_ATTRIBUTE: | ||
| 167 | return $this->createProductManagementAttributeImporter($dataImportConfigurationActionTransfer); | ||
| 168 | case DataImportConfig::IMPORT_TYPE_PRODUCT_ABSTRACT: | ||
| 169 | return $this->createProductAbstractImporter($dataImportConfigurationActionTransfer); | ||
| 170 | case DataImportConfig::IMPORT_TYPE_PRODUCT_ABSTRACT_STORE: | ||
| 171 | return $this->createProductAbstractStoreImporter($dataImportConfigurationActionTransfer); | ||
| 172 | case DataImportConfig::IMPORT_TYPE_PRODUCT_CONCRETE: | ||
| 173 | return $this->createProductConcreteImporter($dataImportConfigurationActionTransfer); | ||
| 174 | case DataImportConfig::IMPORT_TYPE_PRODUCT_IMAGE: | ||
| 175 | return $this->createProductImageImporter($dataImportConfigurationActionTransfer); | ||
| 176 | case DataImportConfig::IMPORT_TYPE_PRODUCT_OPTION: | ||
| 177 | return $this->createProductOptionImporter($dataImportConfigurationActionTransfer); | ||
| 178 | case DataImportConfig::IMPORT_TYPE_PRODUCT_OPTION_PRICE: | ||
| 179 | return $this->createProductOptionPriceImporter($dataImportConfigurationActionTransfer); | ||
| 180 | case DataImportConfig::IMPORT_TYPE_PRODUCT_GROUP: | ||
| 181 | return $this->createProductGroupImporter($dataImportConfigurationActionTransfer); | ||
| 182 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_ABSTRACT: | ||
| 183 | return $this->createCombinedProductAbstractImporter($dataImportConfigurationActionTransfer); | ||
| 184 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_ABSTRACT_STORE: | ||
| 185 | return $this->createCombinedProductAbstractStoreImporter($dataImportConfigurationActionTransfer); | ||
| 186 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_CONCRETE: | ||
| 187 | return $this->createCombinedProductConcreteImporter($dataImportConfigurationActionTransfer); | ||
| 188 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_IMAGE: | ||
| 189 | return $this->createCombinedProductImageImporter($dataImportConfigurationActionTransfer); | ||
| 190 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_PRICE: | ||
| 191 | return $this->createCombinedProductPriceImporter($dataImportConfigurationActionTransfer); | ||
| 192 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_STOCK: | ||
| 193 | return $this->createCombinedProductStockImporter($dataImportConfigurationActionTransfer); | ||
| 194 | case DataImportConfig::IMPORT_TYPE_COMBINED_PRODUCT_GROUP: | ||
| 195 | return $this->createCombinedProductGroupImporter($dataImportConfigurationActionTransfer); | ||
| 196 | case DataImportConfig::IMPORT_TYPE_PRODUCT_REVIEW: | ||
| 197 | return $this->createProductReviewImporter($dataImportConfigurationActionTransfer); | ||
| 198 | case DataImportConfig::IMPORT_TYPE_PRODUCT_SET: | ||
| 199 | return $this->createProductSetImporter($dataImportConfigurationActionTransfer); | ||
| 200 | case DataImportConfig::IMPORT_TYPE_PRODUCT_SEARCH_ATTRIBUTE_MAP: | ||
| 201 | return $this->createProductSearchAttributeMapImporter($dataImportConfigurationActionTransfer); | ||
| 202 | case DataImportConfig::IMPORT_TYPE_PRODUCT_SEARCH_ATTRIBUTE: | ||
| 203 | return $this->createProductSearchAttributeImporter($dataImportConfigurationActionTransfer); | ||
| 204 | case DataImportConfig::IMPORT_TYPE_CMS_TEMPLATE: | ||
| 205 | return $this->createCmsTemplateImporter($dataImportConfigurationActionTransfer); | ||
| 206 | case DataImportConfig::IMPORT_TYPE_CMS_BLOCK: | ||
| 207 | return $this->createCmsBlockImporter($dataImportConfigurationActionTransfer); | ||
| 208 | case DataImportConfig::IMPORT_TYPE_CMS_BLOCK_STORE: | ||
| 209 | return $this->createCmsBlockStoreImporter($dataImportConfigurationActionTransfer); | ||
| 210 | case DataImportConfig::IMPORT_TYPE_DISCOUNT_AMOUNT: | ||
| 211 | return $this->createDiscountAmountImporter($dataImportConfigurationActionTransfer); | ||
| 212 | case DataImportConfig::IMPORT_TYPE_ABSTRACT_GIFT_CARD_CONFIGURATION: | ||
| 213 | return $this->createAbstractGiftCardConfigurationImporter($dataImportConfigurationActionTransfer); | ||
| 214 | case DataImportConfig::IMPORT_TYPE_CONCRETE_GIFT_CARD_CONFIGURATION: | ||
| 215 | return $this->createConcreteGiftCardConfigurationImporter($dataImportConfigurationActionTransfer); | ||
| 216 | case DataImportConfig::IMPORT_TYPE_PRODUCT_STOCK: | ||
| 217 | return $this->createProductStockImporter($dataImportConfigurationActionTransfer); | ||
| 218 | case DataImportConfig::IMPORT_TYPE_NAVIGATION: | ||
| 219 | return $this->createNavigationImporter($dataImportConfigurationActionTransfer); | ||
| 220 | case DataImportConfig::IMPORT_TYPE_NAVIGATION_NODE: | ||
| 221 | return $this->createNavigationNodeImporter($dataImportConfigurationActionTransfer); | ||
| 222 | case DataImportConfig::IMPORT_TYPE_MERCHANT_USER: | ||
| 223 | return $this->createMerchantUserImporter($dataImportConfigurationActionTransfer); | ||
| 224 | default: | ||
| 225 | return null; | ||
| 226 | } | ||
| 227 | } | ||
| 228 | |||
| 229 | /** | ||
| 230 | * @param string $importType | ||
| 231 | * @param \Spryker\Zed\DataImport\Business\Model\DataReader\DataReaderInterface $reader | ||
| 232 | * | ||
| 233 | * @return \Pyz\Zed\DataImport\Business\Model\DataImporterConditional | ||
| 234 | */ | ||
| 235 | public function createDataImporterConditional(string $importType, DataReaderInterface $reader): DataImporterConditional | ||
| 236 |     { | ||
| 237 | return new DataImporterConditional($importType, $reader, $this->getGracefulRunnerFacade()); | ||
| 238 | } | ||
| 239 | |||
| 240 | /** | ||
| 241 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 242 | * | ||
| 243 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 244 | */ | ||
| 245 | protected function createCurrencyImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): DataImporterInterface | ||
| 246 |     { | ||
| 247 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 248 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 249 | ); | ||
| 250 | |||
| 251 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 252 | $dataSetStepBroker->addStep(new CurrencyWriterStep()); | ||
| 253 | |||
| 254 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 255 | |||
| 256 | return $dataImporter; | ||
| 257 | } | ||
| 258 | |||
| 259 | /** | ||
| 260 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 261 | * | ||
| 262 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 263 | */ | ||
| 264 | protected function createGlossaryImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): DataImporterInterface | ||
| 265 |     { | ||
| 266 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 267 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 268 | ); | ||
| 269 | |||
| 270 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(GlossaryWriterStep::BULK_SIZE); | ||
| 271 | $dataSetStepBroker | ||
| 272 | ->addStep($this->createLocaleNameToIdStep(GlossaryWriterStep::KEY_LOCALE)) | ||
| 273 | ->addStep(new GlossaryWriterStep()); | ||
| 274 | |||
| 275 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 276 | |||
| 277 | return $dataImporter; | ||
| 278 | } | ||
| 279 | |||
| 280 | /** | ||
| 281 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 282 | * | ||
| 283 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 284 | */ | ||
| 285 | public function createMerchantUserImporter( | ||
| 286 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 287 |     ): DataImporterInterface { | ||
| 288 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 289 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 290 | ); | ||
| 291 | |||
| 292 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 293 | $dataSetStepBroker->addStep(new MerchantUserWriterStep( | ||
| 294 | $this->getMerchantUserFacade(), | ||
| 295 | )); | ||
| 296 | |||
| 297 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 298 | |||
| 299 | return $dataImporter; | ||
| 300 | } | ||
| 301 | |||
| 302 | /** | ||
| 303 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 304 | * | ||
| 305 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 306 | */ | ||
| 307 | protected function createCategoryTemplateImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer): DataImporterInterface | ||
| 308 |     { | ||
| 309 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 310 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 311 | ); | ||
| 312 | |||
| 313 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 314 | $dataSetStepBroker | ||
| 315 | ->addStep(new CategoryTemplateWriterStep()); | ||
| 316 | |||
| 317 | $dataImporter | ||
| 318 | ->addDataSetStepBroker($dataSetStepBroker); | ||
| 319 | |||
| 320 | return $dataImporter; | ||
| 321 | } | ||
| 322 | |||
| 323 | /** | ||
| 324 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 325 | * | ||
| 326 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 327 | */ | ||
| 328 | protected function createCustomerImporter( | ||
| 329 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 330 |     ): DataImporterInterface { | ||
| 331 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 332 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 333 | ); | ||
| 334 | |||
| 335 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 336 | $dataSetStepBroker->addStep(new CustomerWriterStep()); | ||
| 337 | |||
| 338 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 339 | |||
| 340 | return $dataImporter; | ||
| 341 | } | ||
| 342 | |||
| 343 | /** | ||
| 344 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 345 | * | ||
| 346 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 347 | */ | ||
| 348 | protected function createCmsTemplateImporter( | ||
| 349 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 350 |     ): DataImporterInterface { | ||
| 351 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 352 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 353 | ); | ||
| 354 | |||
| 355 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 356 | $dataSetStepBroker | ||
| 357 | ->addStep(new CmsTemplateWriterStep()); | ||
| 358 | |||
| 359 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 360 | |||
| 361 | return $dataImporter; | ||
| 362 | } | ||
| 363 | |||
| 364 | /** | ||
| 365 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 366 | * | ||
| 367 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 368 | */ | ||
| 369 | protected function createCmsBlockImporter( | ||
| 370 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 371 |     ): DataImporterInterface { | ||
| 372 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 373 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 374 | ); | ||
| 375 | |||
| 376 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CmsBlockWriterStep::BULK_SIZE); | ||
| 377 | $dataSetStepBroker | ||
| 378 | ->addStep($this->createAddLocalesStep()) | ||
| 379 | ->addStep($this->createLocalizedAttributesExtractorStep([ | ||
| 380 | CmsBlockWriterStep::KEY_PLACEHOLDER_TITLE, | ||
| 381 | CmsBlockWriterStep::KEY_PLACEHOLDER_DESCRIPTION, | ||
| 382 | CmsBlockWriterStep::KEY_PLACEHOLDER_CONTENT, | ||
| 383 | CmsBlockWriterStep::KEY_PLACEHOLDER_LINK, | ||
| 384 | ])) | ||
| 385 | ->addStep(new CmsBlockWriterStep()); | ||
| 386 | |||
| 387 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 388 | |||
| 389 | return $dataImporter; | ||
| 390 | } | ||
| 391 | |||
| 392 | /** | ||
| 393 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 394 | * | ||
| 395 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 396 | */ | ||
| 397 | protected function createCmsBlockStoreImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 398 |     { | ||
| 399 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 400 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 401 | ); | ||
| 402 | |||
| 403 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CmsBlockStoreWriterStep::BULK_SIZE); | ||
| 404 | $dataSetStepBroker->addStep(new CmsBlockStoreWriterStep()); | ||
| 405 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 406 | |||
| 407 | return $dataImporter; | ||
| 408 | } | ||
| 409 | |||
| 410 | /** | ||
| 411 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 412 | * | ||
| 413 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 414 | */ | ||
| 415 | protected function createDiscountImporter( | ||
| 416 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 417 |     ): DataImporterInterface { | ||
| 418 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 419 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 420 | ); | ||
| 421 | |||
| 422 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(DiscountWriterStep::BULK_SIZE); | ||
| 423 | $dataSetStepBroker | ||
| 424 | ->addStep(new DiscountWriterStep()); | ||
| 425 | |||
| 426 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 427 | |||
| 428 | return $dataImporter; | ||
| 429 | } | ||
| 430 | |||
| 431 | /** | ||
| 432 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 433 | * | ||
| 434 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 435 | */ | ||
| 436 | protected function createDiscountStoreImporter( | ||
| 437 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 438 |     ): DataImporterInterface { | ||
| 439 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 440 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 441 | ); | ||
| 442 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(DiscountStoreWriterStep::BULK_SIZE); | ||
| 443 | $dataSetStepBroker | ||
| 444 | ->addStep(new DiscountStoreWriterStep()); | ||
| 445 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 446 | |||
| 447 | return $dataImporter; | ||
| 448 | } | ||
| 449 | |||
| 450 | /** | ||
| 451 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 452 | * | ||
| 453 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 454 | */ | ||
| 455 | protected function createDiscountAmountImporter( | ||
| 456 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 457 |     ): DataImporterInterface { | ||
| 458 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 459 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 460 | ); | ||
| 461 | |||
| 462 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(DiscountAmountWriterStep::BULK_SIZE); | ||
| 463 | $dataSetStepBroker | ||
| 464 | ->addStep(new DiscountAmountWriterStep()); | ||
| 465 | |||
| 466 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 467 | |||
| 468 | return $dataImporter; | ||
| 469 | } | ||
| 470 | |||
| 471 | /** | ||
| 472 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 473 | * | ||
| 474 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 475 | */ | ||
| 476 | protected function createDiscountVoucherImporter( | ||
| 477 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 478 |     ): DataImporterInterface { | ||
| 479 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 480 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 481 | ); | ||
| 482 | |||
| 483 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(DiscountVoucherWriterStep::BULK_SIZE); | ||
| 484 | $dataSetStepBroker | ||
| 485 | ->addStep(new DiscountVoucherWriterStep($this->createDiscountConfig())); | ||
| 486 | |||
| 487 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 488 | |||
| 489 | return $dataImporter; | ||
| 490 | } | ||
| 491 | |||
| 492 | /** | ||
| 493 | * @return \Spryker\Zed\Discount\DiscountConfig | ||
| 494 | */ | ||
| 495 | protected function createDiscountConfig(): DiscountConfig | ||
| 496 |     { | ||
| 497 | return new DiscountConfig(); | ||
| 498 | } | ||
| 499 | |||
| 500 | /** | ||
| 501 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 502 | * | ||
| 503 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 504 | */ | ||
| 505 | protected function createProductOptionImporter( | ||
| 506 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 507 |     ): DataImporterInterface { | ||
| 508 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 509 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 510 | ); | ||
| 511 | |||
| 512 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 513 | $dataSetStepBroker | ||
| 514 | ->addStep($this->createAddLocalesStep()) | ||
| 515 | ->addStep($this->createTaxSetNameToIdTaxSetStep(ProductOptionWriterStep::KEY_TAX_SET_NAME)) | ||
| 516 | ->addStep($this->createLocalizedAttributesExtractorStep([ | ||
| 517 | ProductOptionWriterStep::KEY_GROUP_NAME, | ||
| 518 | ProductOptionWriterStep::KEY_OPTION_NAME, | ||
| 519 | ])) | ||
| 520 | ->addStep(new ProductOptionWriterStep()); | ||
| 521 | |||
| 522 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 523 | |||
| 524 | return $dataImporter; | ||
| 525 | } | ||
| 526 | |||
| 527 | /** | ||
| 528 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 529 | * | ||
| 530 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 531 | */ | ||
| 532 | protected function createProductOptionPriceImporter( | ||
| 533 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 534 |     ): DataImporterInterface { | ||
| 535 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 536 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 537 | ); | ||
| 538 | |||
| 539 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 540 | $dataSetStepBroker | ||
| 541 | ->addStep(new ProductOptionPriceWriterStep()); | ||
| 542 | |||
| 543 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 544 | |||
| 545 | return $dataImporter; | ||
| 546 | } | ||
| 547 | |||
| 548 | /** | ||
| 549 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 550 | * | ||
| 551 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 552 | */ | ||
| 553 | public function createProductStockImporter( | ||
| 554 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 555 |     ): DataImporterInterface { | ||
| 556 | /** @var \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterInterface $dataImporter */ | ||
| 557 | $dataImporter = $this->getCsvDataImporterWriterAwareFromConfig( | ||
| 558 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 559 | ); | ||
| 560 | |||
| 561 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductStockHydratorStep::BULK_SIZE); | ||
| 562 | $dataSetStepBroker | ||
| 563 | ->addStep(new ProductStockHydratorStep()); | ||
| 564 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 565 | $dataImporter->setDataSetWriter($this->createProductStockDataImportWriters()); | ||
| 566 | |||
| 567 | return $dataImporter; | ||
| 568 | } | ||
| 569 | |||
| 570 | /** | ||
| 571 | * @return \Pyz\Zed\DataImport\Business\Model\ProductStock\Hook\ProductStockAfterImportPublishHook | ||
| 572 | */ | ||
| 573 | protected function createProductStockAfterImportPublishHook(): ProductStockAfterImportPublishHook | ||
| 574 |     { | ||
| 575 | return new ProductStockAfterImportPublishHook(); | ||
| 576 | } | ||
| 577 | |||
| 578 | /** | ||
| 579 | * @return \Spryker\Zed\Availability\Business\AvailabilityFacadeInterface | ||
| 580 | */ | ||
| 581 | protected function getAvailabilityFacade(): AvailabilityFacadeInterface | ||
| 582 |     { | ||
| 583 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_AVAILABILITY); | ||
|  | |||
| 584 | } | ||
| 585 | |||
| 586 | /** | ||
| 587 | * @return \Spryker\Zed\ProductBundle\Business\ProductBundleFacadeInterface | ||
| 588 | */ | ||
| 589 | protected function getProductBundleFacade(): ProductBundleFacadeInterface | ||
| 590 |     { | ||
| 591 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_PRODUCT_BUNDLE); | ||
| 592 | } | ||
| 593 | |||
| 594 | /** | ||
| 595 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 596 | * | ||
| 597 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 598 | */ | ||
| 599 | public function createProductImageImporter( | ||
| 600 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 601 |     ): DataImporterInterface { | ||
| 602 | /** @var \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterDataSetWriterAwareInterface $dataImporter */ | ||
| 603 | $dataImporter = $this->getCsvDataImporterWriterAwareFromConfig( | ||
| 604 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 605 | ); | ||
| 606 | |||
| 607 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductImageHydratorStep::BULK_SIZE); | ||
| 608 | $dataSetStepBroker | ||
| 609 | ->addStep($this->createProductAbstractSkuToIdProductAbstractStep(ProductImageHydratorStep::COLUMN_ABSTRACT_SKU, ProductImageHydratorStep::KEY_IMAGE_SET_FK_PRODUCT_ABSTRACT)) | ||
| 610 | ->addStep($this->createProductSkuToIdProductStep(ProductImageHydratorStep::COLUMN_CONCRETE_SKU, ProductImageHydratorStep::KEY_IMAGE_SET_FK_PRODUCT)) | ||
| 611 | ->addStep($this->createLocaleNameToIdStep(ProductImageHydratorStep::COLUMN_LOCALE, ProductImageHydratorStep::KEY_IMAGE_SET_FK_LOCALE)) | ||
| 612 | ->addStep(new ProductImageHydratorStep()) | ||
| 613 | ->addStep($this->createAddLocalesStep()) | ||
| 614 | ->addStep($this->createLocalizedAttributesExtractorStep([ | ||
| 615 | CombinedProductImagePropelDataSetWriter::KEY_ALT_TEXT_SMALL, | ||
| 616 | CombinedProductImagePropelDataSetWriter::KEY_ALT_TEXT_LARGE, | ||
| 617 | ])); | ||
| 618 | |||
| 619 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 620 | $dataImporter->setDataSetWriter($this->createProductImageDataWriters()); | ||
| 621 | |||
| 622 | return $dataImporter; | ||
| 623 | } | ||
| 624 | |||
| 625 | /** | ||
| 626 | * @return \Pyz\Zed\DataImport\Business\Model\Locale\Repository\LocaleRepositoryInterface | ||
| 627 | */ | ||
| 628 | protected function createLocaleRepository(): LocaleRepositoryInterface | ||
| 629 |     { | ||
| 630 | return new LocaleRepository(); | ||
| 631 | } | ||
| 632 | |||
| 633 | /** | ||
| 634 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 635 | * | ||
| 636 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 637 | */ | ||
| 638 | protected function createTaxImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 639 |     { | ||
| 640 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 641 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 642 | ); | ||
| 643 | |||
| 644 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(TaxWriterStep::BULK_SIZE); | ||
| 645 | $dataSetStepBroker | ||
| 646 | ->addStep(new TaxWriterStep($this->createCountryRepository())); | ||
| 647 | |||
| 648 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 649 | |||
| 650 | return $dataImporter; | ||
| 651 | } | ||
| 652 | |||
| 653 | /** | ||
| 654 | * @return \Pyz\Zed\DataImport\Business\Model\Country\Repository\CountryRepositoryInterface | ||
| 655 | */ | ||
| 656 | protected function createCountryRepository(): CountryRepositoryInterface | ||
| 657 |     { | ||
| 658 | return new CountryRepository(); | ||
| 659 | } | ||
| 660 | |||
| 661 | /** | ||
| 662 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 663 | * | ||
| 664 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 665 | */ | ||
| 666 | protected function createNavigationImporter( | ||
| 667 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 668 |     ): DataImporterInterface { | ||
| 669 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 670 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 671 | ); | ||
| 672 | |||
| 673 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(NavigationWriterStep::BULK_SIZE); | ||
| 674 | $dataSetStepBroker | ||
| 675 | ->addStep(new NavigationWriterStep()); | ||
| 676 | |||
| 677 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 678 | |||
| 679 | return $dataImporter; | ||
| 680 | } | ||
| 681 | |||
| 682 | /** | ||
| 683 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 684 | * | ||
| 685 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 686 | */ | ||
| 687 | protected function createNavigationNodeImporter( | ||
| 688 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 689 |     ): DataImporterInterface { | ||
| 690 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 691 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 692 | ); | ||
| 693 | |||
| 694 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(NavigationNodeWriterStep::BULK_SIZE); | ||
| 695 | $dataSetStepBroker | ||
| 696 | ->addStep($this->createAddLocalesStep()) | ||
| 697 | ->addStep($this->createNavigationKeyToIdNavigationStep(NavigationNodeWriterStep::KEY_NAVIGATION_KEY)) | ||
| 698 | ->addStep($this->createLocalizedAttributesExtractorStep([ | ||
| 699 | NavigationNodeWriterStep::KEY_TITLE, | ||
| 700 | NavigationNodeWriterStep::KEY_URL, | ||
| 701 | NavigationNodeWriterStep::KEY_CSS_CLASS, | ||
| 702 | ])) | ||
| 703 | ->addStep($this->createNavigationNodeValidityDatesStep(NavigationNodeWriterStep::KEY_VALID_FROM, NavigationNodeWriterStep::KEY_VALID_TO)) | ||
| 704 | ->addStep(new NavigationNodeWriterStep()); | ||
| 705 | |||
| 706 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 707 | |||
| 708 | return $dataImporter; | ||
| 709 | } | ||
| 710 | |||
| 711 | /** | ||
| 712 | * @param string $source | ||
| 713 | * @param string $target | ||
| 714 | * | ||
| 715 | * @return \Pyz\Zed\DataImport\Business\Model\Navigation\NavigationKeyToIdNavigationStep | ||
| 716 | */ | ||
| 717 | protected function createNavigationKeyToIdNavigationStep( | ||
| 718 | string $source = NavigationKeyToIdNavigationStep::KEY_SOURCE, | ||
| 719 | string $target = NavigationKeyToIdNavigationStep::KEY_TARGET, | ||
| 720 |     ): NavigationKeyToIdNavigationStep { | ||
| 721 | return new NavigationKeyToIdNavigationStep($source, $target); | ||
| 722 | } | ||
| 723 | |||
| 724 | /** | ||
| 725 | * @param string $keyValidFrom | ||
| 726 | * @param string $keyValidTo | ||
| 727 | * | ||
| 728 | * @return \Pyz\Zed\DataImport\Business\Model\NavigationNode\NavigationNodeValidityDatesStep | ||
| 729 | */ | ||
| 730 | protected function createNavigationNodeValidityDatesStep( | ||
| 731 | string $keyValidFrom, | ||
| 732 | string $keyValidTo, | ||
| 733 |     ): NavigationNodeValidityDatesStep { | ||
| 734 | return new NavigationNodeValidityDatesStep($keyValidFrom, $keyValidTo); | ||
| 735 | } | ||
| 736 | |||
| 737 | /** | ||
| 738 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 739 | * | ||
| 740 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 741 | */ | ||
| 742 | public function createProductAbstractImporter( | ||
| 743 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 744 |     ): DataImporterInterface { | ||
| 745 | /** @var \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterInterface $dataImporter */ | ||
| 746 | $dataImporter = $this->getCsvDataImporterWriterAwareFromConfig( | ||
| 747 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 748 | ); | ||
| 749 | |||
| 750 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductAbstractHydratorStep::BULK_SIZE); | ||
| 751 | $dataSetStepBroker | ||
| 752 | ->addStep($this->createProductAbstractCheckExistenceStep()) | ||
| 753 | ->addStep($this->createAddLocalesStep()) | ||
| 754 | ->addStep($this->createAddCategoryKeysStep()) | ||
| 755 | ->addStep($this->createTaxSetNameToIdTaxSetStep(ProductAbstractHydratorStep::COLUMN_TAX_SET_NAME)) | ||
| 756 | ->addStep($this->createAttributesExtractorStep()) | ||
| 757 | ->addStep($this->createProductLocalizedAttributesExtractorStep([ | ||
| 758 | ProductAbstractHydratorStep::COLUMN_NAME, | ||
| 759 | ProductAbstractHydratorStep::COLUMN_URL, | ||
| 760 | ProductAbstractHydratorStep::COLUMN_DESCRIPTION, | ||
| 761 | ProductAbstractHydratorStep::COLUMN_META_TITLE, | ||
| 762 | ProductAbstractHydratorStep::COLUMN_META_DESCRIPTION, | ||
| 763 | ProductAbstractHydratorStep::COLUMN_META_KEYWORDS, | ||
| 764 | ])) | ||
| 765 | ->addStep(new ProductAbstractHydratorStep()); | ||
| 766 | |||
| 767 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 768 | $dataImporter->setDataSetWriter($this->createProductAbstractDataImportWriters()); | ||
| 769 | |||
| 770 | return $dataImporter; | ||
| 771 | } | ||
| 772 | |||
| 773 | /** | ||
| 774 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 775 | * | ||
| 776 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 777 | */ | ||
| 778 | public function createProductAbstractStoreImporter( | ||
| 779 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 780 |     ): DataImporterInterface { | ||
| 781 | /** @var \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterInterface $dataImporter */ | ||
| 782 | $dataImporter = $this->getCsvDataImporterWriterAwareFromConfig( | ||
| 783 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 784 | ); | ||
| 785 | |||
| 786 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductAbstractStoreHydratorStep::BULK_SIZE); | ||
| 787 | $dataSetStepBroker->addStep(new ProductAbstractStoreHydratorStep()); | ||
| 788 | |||
| 789 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 790 | $dataImporter->setDataSetWriter($this->createProductAbstractStoreDataImportWriters()); | ||
| 791 | |||
| 792 | return $dataImporter; | ||
| 793 | } | ||
| 794 | |||
| 795 | /** | ||
| 796 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 797 | * | ||
| 798 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 799 | */ | ||
| 800 | public function createProductConcreteImporter( | ||
| 801 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 802 |     ): DataImporterInterface { | ||
| 803 | /** @var \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterBeforeImportAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterAfterImportAwareInterface|\Spryker\Zed\DataImport\Business\Model\DataImporterDataSetWriterAwareInterface $dataImporter */ | ||
| 804 | $dataImporter = $this->getCsvDataImporterWriterAwareFromConfig( | ||
| 805 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 806 | ); | ||
| 807 | |||
| 808 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductConcreteHydratorStep::BULK_SIZE); | ||
| 809 | $dataSetStepBroker | ||
| 810 | ->addStep($this->createProductConcreteCheckExistenceStep()) | ||
| 811 | ->addStep($this->createAddLocalesStep()) | ||
| 812 | ->addStep($this->createAttributesExtractorStep()) | ||
| 813 | ->addStep($this->createProductConcreteAttributesUniqueCheckStep()) | ||
| 814 | ->addStep($this->createProductLocalizedAttributesExtractorStep([ | ||
| 815 | ProductConcreteHydratorStep::COLUMN_NAME, | ||
| 816 | ProductConcreteHydratorStep::COLUMN_DESCRIPTION, | ||
| 817 | ProductConcreteHydratorStep::COLUMN_IS_SEARCHABLE, | ||
| 818 | ])) | ||
| 819 | ->addStep(new ProductConcreteHydratorStep( | ||
| 820 | $this->createProductRepository(), | ||
| 821 | )); | ||
| 822 | |||
| 823 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 824 | $dataImporter->setDataSetWriter($this->createProductConcreteDataImportWriters()); | ||
| 825 | |||
| 826 | return $dataImporter; | ||
| 827 | } | ||
| 828 | |||
| 829 | /** | ||
| 830 | * @return \Spryker\Zed\DataImport\Business\Model\DataImportStep\DataImportStepInterface | ||
| 831 | */ | ||
| 832 | public function createProductConcreteAttributesUniqueCheckStep(): DataImportStepInterface | ||
| 833 |     { | ||
| 834 | return new ProductConcreteAttributesUniqueCheckStep( | ||
| 835 | $this->createProductRepository(), | ||
| 836 | $this->getUtilEncodingService(), | ||
| 837 | $this->getConfig(), | ||
| 838 | ); | ||
| 839 | } | ||
| 840 | |||
| 841 | /** | ||
| 842 | * @return \Spryker\Zed\DataImport\Business\Model\DataImportStep\DataImportStepInterface | ||
| 843 | */ | ||
| 844 | public function createProductAbstractCheckExistenceStep(): DataImportStepInterface | ||
| 845 |     { | ||
| 846 | return new ProductAbstractCheckExistenceStep( | ||
| 847 | $this->createProductRepository(), | ||
| 848 | ); | ||
| 849 | } | ||
| 850 | |||
| 851 | /** | ||
| 852 | * @return \Spryker\Zed\DataImport\Business\Model\DataImportStep\DataImportStepInterface | ||
| 853 | */ | ||
| 854 | public function createProductConcreteCheckExistenceStep(): DataImportStepInterface | ||
| 855 |     { | ||
| 856 | return new ProductConcreteCheckExistenceStep( | ||
| 857 | $this->createProductRepository(), | ||
| 858 | ); | ||
| 859 | } | ||
| 860 | |||
| 861 | /** | ||
| 862 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 863 | */ | ||
| 864 | protected function createProductAbstractDataImportWriters(): DataSetWriterInterface | ||
| 865 |     { | ||
| 866 | return new DataSetWriterCollection($this->createProductAbstractWriterPlugins()); | ||
| 867 | } | ||
| 868 | |||
| 869 | /** | ||
| 870 | * @return list<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 871 | */ | ||
| 872 | protected function createProductAbstractWriterPlugins(): array | ||
| 873 |     { | ||
| 874 | return [ | ||
| 875 | new ProductAbstractPropelWriterPlugin(), | ||
| 876 | ]; | ||
| 877 | } | ||
| 878 | |||
| 879 | /** | ||
| 880 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 881 | */ | ||
| 882 | protected function createProductConcreteDataImportWriters(): DataSetWriterInterface | ||
| 883 |     { | ||
| 884 | return new DataSetWriterCollection($this->createProductConcreteWriterPlugins()); | ||
| 885 | } | ||
| 886 | |||
| 887 | /** | ||
| 888 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 889 | */ | ||
| 890 | protected function createProductConcreteWriterPlugins(): array | ||
| 891 |     { | ||
| 892 | return [ | ||
| 893 | new ProductConcretePropelWriterPlugin(), | ||
| 894 | ]; | ||
| 895 | } | ||
| 896 | |||
| 897 | /** | ||
| 898 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 899 | */ | ||
| 900 | protected function createProductImageDataWriters(): DataSetWriterInterface | ||
| 901 |     { | ||
| 902 | return new DataSetWriterCollection($this->createProductImageWriterPlugins()); | ||
| 903 | } | ||
| 904 | |||
| 905 | /** | ||
| 906 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 907 | */ | ||
| 908 | protected function createProductImageWriterPlugins(): array | ||
| 909 |     { | ||
| 910 | return [ | ||
| 911 | new ProductImagePropelWriterPlugin(), | ||
| 912 | ]; | ||
| 913 | } | ||
| 914 | |||
| 915 | /** | ||
| 916 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 917 | */ | ||
| 918 | protected function createProductStockDataImportWriters(): DataSetWriterInterface | ||
| 919 |     { | ||
| 920 | return new DataSetWriterCollection($this->createProductStockWriterPlugins()); | ||
| 921 | } | ||
| 922 | |||
| 923 | /** | ||
| 924 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 925 | */ | ||
| 926 | protected function createProductStockWriterPlugins(): array | ||
| 927 |     { | ||
| 928 | return [ | ||
| 929 | new ProductStockPropelWriterPlugin(), | ||
| 930 | ]; | ||
| 931 | } | ||
| 932 | |||
| 933 | /** | ||
| 934 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 935 | */ | ||
| 936 | protected function createProductAbstractStoreDataImportWriters(): DataSetWriterInterface | ||
| 937 |     { | ||
| 938 | return new DataSetWriterCollection($this->createProductAbstractStoreWriterPlugins()); | ||
| 939 | } | ||
| 940 | |||
| 941 | /** | ||
| 942 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 943 | */ | ||
| 944 | protected function createProductAbstractStoreWriterPlugins(): array | ||
| 945 |     { | ||
| 946 | return [ | ||
| 947 | new ProductAbstractStorePropelWriterPlugin(), | ||
| 948 | ]; | ||
| 949 | } | ||
| 950 | |||
| 951 | /** | ||
| 952 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 953 | */ | ||
| 954 | public function createProductAbstractPropelWriter(): DataSetWriterInterface | ||
| 955 |     { | ||
| 956 | return new ProductAbstractPropelDataSetWriter($this->createProductRepository()); | ||
| 957 | } | ||
| 958 | |||
| 959 | /** | ||
| 960 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 961 | */ | ||
| 962 | public function createProductConcretePropelWriter(): DataSetWriterInterface | ||
| 963 |     { | ||
| 964 | return new ProductConcretePropelDataSetWriter($this->createProductRepository()); | ||
| 965 | } | ||
| 966 | |||
| 967 | /** | ||
| 968 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 969 | */ | ||
| 970 | public function createProductImagePropelWriter(): DataSetWriterInterface | ||
| 971 |     { | ||
| 972 | return new ProductImagePropelDataSetWriter($this->createProductImageRepository()); | ||
| 973 | } | ||
| 974 | |||
| 975 | /** | ||
| 976 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 977 | */ | ||
| 978 | public function createProductStockPropelWriter(): DataSetWriterInterface | ||
| 979 |     { | ||
| 980 | return new ProductStockPropelDataSetWriter( | ||
| 981 | $this->getProductBundleFacade(), | ||
| 982 | $this->createProductRepository(), | ||
| 983 | $this->getStoreFacade(), | ||
| 984 | $this->getStockFacade(), | ||
| 985 | ); | ||
| 986 | } | ||
| 987 | |||
| 988 | /** | ||
| 989 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 990 | */ | ||
| 991 | public function createProductAbstractStorePropelWriter(): DataSetWriterInterface | ||
| 992 |     { | ||
| 993 | return new ProductAbstractStorePropelDataSetWriter(); | ||
| 994 | } | ||
| 995 | |||
| 996 | /** | ||
| 997 | * @return \Pyz\Zed\DataImport\Business\Model\Product\Repository\ProductRepository | ||
| 998 | */ | ||
| 999 | protected function createProductRepository(): ProductRepository | ||
| 1000 |     { | ||
| 1001 | return new ProductRepository(); | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | /** | ||
| 1005 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1006 | * | ||
| 1007 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 1008 | */ | ||
| 1009 | protected function createProductAttributeKeyImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 1010 |     { | ||
| 1011 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1012 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1013 | ); | ||
| 1014 | |||
| 1015 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1016 | $dataSetStepBroker | ||
| 1017 | ->addStep(new ProductAttributeKeyWriter()); | ||
| 1018 | |||
| 1019 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1020 | |||
| 1021 | return $dataImporter; | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | /** | ||
| 1025 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1026 | * | ||
| 1027 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1028 | */ | ||
| 1029 | protected function createProductManagementAttributeImporter( | ||
| 1030 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1031 |     ): DataImporterInterface { | ||
| 1032 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1033 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1034 | ); | ||
| 1035 | |||
| 1036 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1037 | $dataSetStepBroker | ||
| 1038 | ->addStep($this->createAddLocalesStep()) | ||
| 1039 | ->addStep($this->createAddProductAttributeKeysStep()) | ||
| 1040 | ->addStep($this->createProductManagementLocalizedAttributesExtractorStep()) | ||
| 1041 | ->addStep(new ProductManagementAttributeWriter()); | ||
| 1042 | |||
| 1043 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1044 | |||
| 1045 | return $dataImporter; | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | /** | ||
| 1049 | * @return \Pyz\Zed\DataImport\Business\Model\ProductManagementAttribute\ProductManagementLocalizedAttributesExtractorStep | ||
| 1050 | */ | ||
| 1051 | protected function createProductManagementLocalizedAttributesExtractorStep(): ProductManagementLocalizedAttributesExtractorStep | ||
| 1052 |     { | ||
| 1053 | return new ProductManagementLocalizedAttributesExtractorStep(); | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | /** | ||
| 1057 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1058 | * | ||
| 1059 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1060 | */ | ||
| 1061 | protected function createProductGroupImporter( | ||
| 1062 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1063 |     ): DataImporterInterface { | ||
| 1064 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1065 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1066 | ); | ||
| 1067 | |||
| 1068 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(ProductGroupWriter::BULK_SIZE); | ||
| 1069 | $dataSetStepBroker | ||
| 1070 | ->addStep(new ProductGroupWriter( | ||
| 1071 | $this->createProductRepository(), | ||
| 1072 | )); | ||
| 1073 | |||
| 1074 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1075 | |||
| 1076 | return $dataImporter; | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | /** | ||
| 1080 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1081 | * | ||
| 1082 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 1083 | */ | ||
| 1084 | protected function createAbstractGiftCardConfigurationImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 1085 |     { | ||
| 1086 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1087 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1088 | ); | ||
| 1089 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(GiftCardAbstractConfigurationWriterStep::BULK_SIZE); | ||
| 1090 | $dataSetStepBroker | ||
| 1091 | ->addStep(new GiftCardAbstractConfigurationWriterStep($this->createProductRepository())); | ||
| 1092 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1093 | |||
| 1094 | return $dataImporter; | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | /** | ||
| 1098 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1099 | * | ||
| 1100 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 1101 | */ | ||
| 1102 | protected function createConcreteGiftCardConfigurationImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 1103 |     { | ||
| 1104 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1105 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1106 | ); | ||
| 1107 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(GiftCardConcreteConfigurationWriterStep::BULK_SIZE); | ||
| 1108 | $dataSetStepBroker | ||
| 1109 | ->addStep(new GiftCardConcreteConfigurationWriterStep($this->createProductRepository())); | ||
| 1110 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1111 | |||
| 1112 | return $dataImporter; | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | /** | ||
| 1116 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1117 | * | ||
| 1118 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface|\Spryker\Zed\DataImport\Business\Model\DataSet\DataSetStepBrokerAwareInterface | ||
| 1119 | */ | ||
| 1120 | protected function createProductReviewImporter(DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer) | ||
| 1121 |     { | ||
| 1122 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1123 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1124 | ); | ||
| 1125 | |||
| 1126 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1127 | $dataSetStepBroker->addStep(new ProductReviewWriterStep( | ||
| 1128 | $this->createProductRepository(), | ||
| 1129 | $this->createLocaleRepository(), | ||
| 1130 | )); | ||
| 1131 | |||
| 1132 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1133 | |||
| 1134 | return $dataImporter; | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | /** | ||
| 1138 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1139 | * | ||
| 1140 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1141 | */ | ||
| 1142 | protected function createProductSetImporter( | ||
| 1143 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1144 |     ): DataImporterInterface { | ||
| 1145 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1146 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1147 | ); | ||
| 1148 | |||
| 1149 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1150 | $dataSetStepBroker | ||
| 1151 | ->addStep($this->createAddProductAbstractSkusStep()) | ||
| 1152 | ->addStep($this->createAddLocalesStep()) | ||
| 1153 | ->addStep($this->createProductSetImageExtractorStep()) | ||
| 1154 | ->addStep($this->createProductSetImageLocalizedAttributesExtractorStep()) | ||
| 1155 | ->addStep($this->createLocalizedAttributesExtractorStep([ | ||
| 1156 | ProductSetWriterStep::KEY_NAME, | ||
| 1157 | ProductSetWriterStep::KEY_URL, | ||
| 1158 | ProductSetWriterStep::KEY_DESCRIPTION, | ||
| 1159 | ProductSetWriterStep::KEY_META_TITLE, | ||
| 1160 | ProductSetWriterStep::KEY_META_DESCRIPTION, | ||
| 1161 | ProductSetWriterStep::KEY_META_KEYWORDS, | ||
| 1162 | ])) | ||
| 1163 | ->addStep(new ProductSetWriterStep( | ||
| 1164 | $this->createProductRepository(), | ||
| 1165 | )); | ||
| 1166 | |||
| 1167 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1168 | |||
| 1169 | return $dataImporter; | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | /** | ||
| 1173 | * @return \Pyz\Zed\DataImport\Business\Model\ProductSet\ProductSetImageExtractorStep | ||
| 1174 | */ | ||
| 1175 | protected function createProductSetImageExtractorStep(): ProductSetImageExtractorStep | ||
| 1176 |     { | ||
| 1177 | return new ProductSetImageExtractorStep(); | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | /** | ||
| 1181 | * @return \Pyz\Zed\DataImport\Business\Model\ProductSet\ProductSetImageLocalizedAttributesExtractorStep | ||
| 1182 | */ | ||
| 1183 | protected function createProductSetImageLocalizedAttributesExtractorStep(): ProductSetImageLocalizedAttributesExtractorStep | ||
| 1184 |     { | ||
| 1185 | return new ProductSetImageLocalizedAttributesExtractorStep(); | ||
| 1186 | } | ||
| 1187 | |||
| 1188 | /** | ||
| 1189 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1190 | * | ||
| 1191 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1192 | */ | ||
| 1193 | protected function createProductSearchAttributeMapImporter( | ||
| 1194 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1195 |     ): DataImporterInterface { | ||
| 1196 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1197 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1198 | ); | ||
| 1199 | |||
| 1200 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1201 | $dataSetStepBroker | ||
| 1202 | ->addStep($this->createAddProductAttributeKeysStep()) | ||
| 1203 | ->addStep(new ProductSearchAttributeMapWriter()); | ||
| 1204 | |||
| 1205 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1206 | |||
| 1207 | return $dataImporter; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | /** | ||
| 1211 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1212 | * | ||
| 1213 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1214 | */ | ||
| 1215 | protected function createProductSearchAttributeImporter( | ||
| 1216 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1217 |     ): DataImporterInterface { | ||
| 1218 | $dataImporter = $this->getCsvDataImporterFromConfig( | ||
| 1219 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1220 | ); | ||
| 1221 | |||
| 1222 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(); | ||
| 1223 | $dataSetStepBroker | ||
| 1224 | ->addStep($this->createAddLocalesStep()) | ||
| 1225 | ->addStep($this->createAddProductAttributeKeysStep()) | ||
| 1226 | ->addStep($this->createLocalizedAttributesExtractorStep([ProductSearchAttributeWriter::KEY])) | ||
| 1227 | ->addStep(new ProductSearchAttributeWriter( | ||
| 1228 | $this->createSearchGlossaryKeyBuilder(), | ||
| 1229 | )); | ||
| 1230 | |||
| 1231 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1232 | $dataImporter->addAfterImportHook($this->createProductSearchAfterImportHook()); | ||
| 1233 | |||
| 1234 | return $dataImporter; | ||
| 1235 | } | ||
| 1236 | |||
| 1237 | /** | ||
| 1238 | * @return \Pyz\Zed\DataImport\Business\Model\ProductSearchAttribute\Hook\ProductSearchAfterImportHook | ||
| 1239 | */ | ||
| 1240 | protected function createProductSearchAfterImportHook(): ProductSearchAfterImportHook | ||
| 1241 |     { | ||
| 1242 | return new ProductSearchAfterImportHook(); | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | /** | ||
| 1246 | * @return \Spryker\Shared\ProductSearch\Code\KeyBuilder\FilterGlossaryKeyBuilder | ||
| 1247 | */ | ||
| 1248 | protected function createSearchGlossaryKeyBuilder(): FilterGlossaryKeyBuilder | ||
| 1249 |     { | ||
| 1250 | return new FilterGlossaryKeyBuilder(); | ||
| 1251 | } | ||
| 1252 | |||
| 1253 | /** | ||
| 1254 | * @return \Pyz\Zed\DataImport\Business\Model\ProductAbstract\AddCategoryKeysStep | ||
| 1255 | */ | ||
| 1256 | protected function createAddCategoryKeysStep(): AddCategoryKeysStep | ||
| 1257 |     { | ||
| 1258 | return new AddCategoryKeysStep(); | ||
| 1259 | } | ||
| 1260 | |||
| 1261 | /** | ||
| 1262 | * @return \Pyz\Zed\DataImport\Business\Model\Product\AttributesExtractorStep | ||
| 1263 | */ | ||
| 1264 | protected function createAttributesExtractorStep(): AttributesExtractorStep | ||
| 1265 |     { | ||
| 1266 | return new AttributesExtractorStep(); | ||
| 1267 | } | ||
| 1268 | |||
| 1269 | /** | ||
| 1270 | * @return \Pyz\Zed\DataImport\Business\Model\Product\AttributesExtractorStep | ||
| 1271 | */ | ||
| 1272 | protected function createCombinedAttributesExtractorStep(): AttributesExtractorStep | ||
| 1273 |     { | ||
| 1274 | return new CombinedAttributesExtractorStep(); | ||
| 1275 | } | ||
| 1276 | |||
| 1277 | /** | ||
| 1278 | * @param array<string> $defaultAttributes | ||
| 1279 | * | ||
| 1280 | * @return \Pyz\Zed\DataImport\Business\Model\Product\ProductLocalizedAttributesExtractorStep | ||
| 1281 | */ | ||
| 1282 | protected function createProductLocalizedAttributesExtractorStep( | ||
| 1283 | array $defaultAttributes = [], | ||
| 1284 |     ): ProductLocalizedAttributesExtractorStep { | ||
| 1285 | return new ProductLocalizedAttributesExtractorStep($defaultAttributes); | ||
| 1286 | } | ||
| 1287 | |||
| 1288 | /** | ||
| 1289 | * @param array<string> $defaultAttributes | ||
| 1290 | * | ||
| 1291 | * @return \Pyz\Zed\DataImport\Business\Model\Product\ProductLocalizedAttributesExtractorStep | ||
| 1292 | */ | ||
| 1293 | protected function createCombinedProductLocalizedAttributesExtractorStep( | ||
| 1294 | array $defaultAttributes = [], | ||
| 1295 |     ): ProductLocalizedAttributesExtractorStep { | ||
| 1296 | return new CombinedProductLocalizedAttributesExtractorStep($defaultAttributes); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | /** | ||
| 1300 | * @return \Pyz\Zed\DataImport\Business\Model\ProductAbstract\AddProductAbstractSkusStep | ||
| 1301 | */ | ||
| 1302 | protected function createAddProductAbstractSkusStep(): AddProductAbstractSkusStep | ||
| 1303 |     { | ||
| 1304 | return new AddProductAbstractSkusStep(); | ||
| 1305 | } | ||
| 1306 | |||
| 1307 | /** | ||
| 1308 | * @param string $source | ||
| 1309 | * @param string $target | ||
| 1310 | * | ||
| 1311 | * @return \Pyz\Zed\DataImport\Business\Model\Locale\LocaleNameToIdLocaleStep | ||
| 1312 | */ | ||
| 1313 | protected function createLocaleNameToIdStep( | ||
| 1314 | string $source = LocaleNameToIdLocaleStep::KEY_SOURCE, | ||
| 1315 | string $target = LocaleNameToIdLocaleStep::KEY_TARGET, | ||
| 1316 |     ): LocaleNameToIdLocaleStep { | ||
| 1317 | return new LocaleNameToIdLocaleStep($source, $target); | ||
| 1318 | } | ||
| 1319 | |||
| 1320 | /** | ||
| 1321 | * @param string $source | ||
| 1322 | * @param string $target | ||
| 1323 | * | ||
| 1324 | * @return \Pyz\Zed\DataImport\Business\Model\ProductAbstract\ProductAbstractSkuToIdProductAbstractStep | ||
| 1325 | */ | ||
| 1326 | protected function createProductAbstractSkuToIdProductAbstractStep( | ||
| 1327 | string $source = ProductAbstractSkuToIdProductAbstractStep::KEY_SOURCE, | ||
| 1328 | string $target = ProductAbstractSkuToIdProductAbstractStep::KEY_TARGET, | ||
| 1329 |     ): ProductAbstractSkuToIdProductAbstractStep { | ||
| 1330 | return new ProductAbstractSkuToIdProductAbstractStep($source, $target); | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | /** | ||
| 1334 | * @param string $source | ||
| 1335 | * @param string $target | ||
| 1336 | * | ||
| 1337 | * @return \Pyz\Zed\DataImport\Business\Model\ProductConcrete\ProductSkuToIdProductStep | ||
| 1338 | */ | ||
| 1339 | protected function createProductSkuToIdProductStep( | ||
| 1340 | string $source = ProductSkuToIdProductStep::KEY_SOURCE, | ||
| 1341 | string $target = ProductSkuToIdProductStep::KEY_TARGET, | ||
| 1342 |     ): ProductSkuToIdProductStep { | ||
| 1343 | return new ProductSkuToIdProductStep($source, $target); | ||
| 1344 | } | ||
| 1345 | |||
| 1346 | /** | ||
| 1347 | * @param string $source | ||
| 1348 | * @param string $target | ||
| 1349 | * | ||
| 1350 | * @return \Pyz\Zed\DataImport\Business\Model\Tax\TaxSetNameToIdTaxSetStep | ||
| 1351 | */ | ||
| 1352 | protected function createTaxSetNameToIdTaxSetStep( | ||
| 1353 | string $source = TaxSetNameToIdTaxSetStep::KEY_SOURCE, | ||
| 1354 | string $target = TaxSetNameToIdTaxSetStep::KEY_TARGET, | ||
| 1355 |     ): TaxSetNameToIdTaxSetStep { | ||
| 1356 | return new TaxSetNameToIdTaxSetStep($source, $target); | ||
| 1357 | } | ||
| 1358 | |||
| 1359 | /** | ||
| 1360 | * @return \Pyz\Zed\DataImport\Business\Model\ProductAttributeKey\AddProductAttributeKeysStep | ||
| 1361 | */ | ||
| 1362 | protected function createAddProductAttributeKeysStep(): AddProductAttributeKeysStep | ||
| 1363 |     { | ||
| 1364 | return new AddProductAttributeKeysStep(); | ||
| 1365 | } | ||
| 1366 | |||
| 1367 | /** | ||
| 1368 | * @return \Spryker\Zed\Event\Business\EventFacadeInterface | ||
| 1369 | */ | ||
| 1370 | protected function getEventFacade(): EventFacadeInterface | ||
| 1371 |     { | ||
| 1372 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_EVENT); | ||
| 1373 | } | ||
| 1374 | |||
| 1375 | /** | ||
| 1376 | * @return \Spryker\Zed\Currency\Business\CurrencyFacadeInterface | ||
| 1377 | */ | ||
| 1378 | protected function getCurrencyFacade(): CurrencyFacadeInterface | ||
| 1379 |     { | ||
| 1380 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_CURRENCY); | ||
| 1381 | } | ||
| 1382 | |||
| 1383 | /** | ||
| 1384 | * @return \Spryker\Zed\PriceProduct\Business\PriceProductFacadeInterface | ||
| 1385 | */ | ||
| 1386 | public function getPriceProductFacade(): PriceProductFacadeInterface | ||
| 1387 |     { | ||
| 1388 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_PRICE_PRODUCT); | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | /** | ||
| 1392 | * @return \Spryker\Zed\Stock\Business\StockFacadeInterface | ||
| 1393 | */ | ||
| 1394 | protected function getStockFacade(): StockFacadeInterface | ||
| 1395 |     { | ||
| 1396 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_STOCK); | ||
| 1397 | } | ||
| 1398 | |||
| 1399 | /** | ||
| 1400 | * @return \Spryker\Zed\Store\Business\StoreFacadeInterface | ||
| 1401 | */ | ||
| 1402 | protected function getStoreFacade(): StoreFacadeInterface | ||
| 1403 |     { | ||
| 1404 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_STORE); | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | /** | ||
| 1408 | * @return \Spryker\Zed\DataImport\Business\Model\DataImportStep\DataImportStepInterface | ||
| 1409 | */ | ||
| 1410 | protected function createAddLocalesStep(): DataImportStepInterface | ||
| 1411 |     { | ||
| 1412 | return new AddLocalesStep($this->getDataImportStoreFacade()); | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | /** | ||
| 1416 | * @return \Pyz\Zed\DataImport\Business\Model\ProductImage\Repository\ProductImageRepositoryInterface | ||
| 1417 | */ | ||
| 1418 | public function createProductImageRepository(): ProductImageRepositoryInterface | ||
| 1419 |     { | ||
| 1420 | return new ProductImageRepository(); | ||
| 1421 | } | ||
| 1422 | |||
| 1423 | /** | ||
| 1424 | * @param string $importType | ||
| 1425 | * @param \Spryker\Zed\DataImport\Business\Model\DataReader\DataReaderInterface $reader | ||
| 1426 | * | ||
| 1427 | * @return \Pyz\Zed\DataImport\Business\Model\DataImporterDataSetWriterAwareConditional | ||
| 1428 | */ | ||
| 1429 | public function createDataImporterWriterAwareConditional( | ||
| 1430 | string $importType, | ||
| 1431 | DataReaderInterface $reader, | ||
| 1432 |     ): DataImporterDataSetWriterAwareConditional { | ||
| 1433 | return new DataImporterDataSetWriterAwareConditional($importType, $reader, $this->getGracefulRunnerFacade()); | ||
| 1434 | } | ||
| 1435 | |||
| 1436 | /** | ||
| 1437 | * @param \Generated\Shared\Transfer\DataImporterConfigurationTransfer $dataImporterConfigurationTransfer | ||
| 1438 | * | ||
| 1439 | * @return \Pyz\Zed\DataImport\Business\Model\DataImporterConditional | ||
| 1440 | */ | ||
| 1441 | public function getConditionalCsvDataImporterFromConfig( | ||
| 1442 | DataImporterConfigurationTransfer $dataImporterConfigurationTransfer, | ||
| 1443 |     ): DataImporterConditional { | ||
| 1444 | $csvReader = $this->createCsvReaderFromConfig($dataImporterConfigurationTransfer->getReaderConfiguration()); | ||
| 1445 | |||
| 1446 | return $this->createDataImporterConditional($dataImporterConfigurationTransfer->getImportType(), $csvReader); | ||
| 1447 | } | ||
| 1448 | |||
| 1449 | /** | ||
| 1450 | * @param \Generated\Shared\Transfer\DataImporterConfigurationTransfer $dataImporterConfigurationTransfer | ||
| 1451 | * | ||
| 1452 | * @return \Pyz\Zed\DataImport\Business\Model\DataImporterDataSetWriterAwareConditional | ||
| 1453 | */ | ||
| 1454 | public function getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1455 | DataImporterConfigurationTransfer $dataImporterConfigurationTransfer, | ||
| 1456 |     ): DataImporterDataSetWriterAwareConditional { | ||
| 1457 | $csvReader = $this->createCsvReaderFromConfig($dataImporterConfigurationTransfer->getReaderConfiguration()); | ||
| 1458 | |||
| 1459 | return $this->createDataImporterWriterAwareConditional($dataImporterConfigurationTransfer->getImportType(), $csvReader); | ||
| 1460 | } | ||
| 1461 | |||
| 1462 | /** | ||
| 1463 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1464 | */ | ||
| 1465 | public function createCombinedProductPricePropelDataSetWriter(): DataSetWriterInterface | ||
| 1466 |     { | ||
| 1467 | return new CombinedProductPricePropelDataSetWriter( | ||
| 1468 | $this->createProductRepository(), | ||
| 1469 | $this->getStoreFacade(), | ||
| 1470 | $this->getCurrencyFacade(), | ||
| 1471 | ); | ||
| 1472 | } | ||
| 1473 | |||
| 1474 | /** | ||
| 1475 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1476 | */ | ||
| 1477 | public function createCombinedProductImagePropelDataSetWriter(): DataSetWriterInterface | ||
| 1478 |     { | ||
| 1479 | return new CombinedProductImagePropelDataSetWriter( | ||
| 1480 | $this->createProductImageRepository(), | ||
| 1481 | ); | ||
| 1482 | } | ||
| 1483 | |||
| 1484 | /** | ||
| 1485 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1486 | */ | ||
| 1487 | public function createCombinedProductStockPropelDataSetWriter(): DataSetWriterInterface | ||
| 1488 |     { | ||
| 1489 | return new CombinedProductStockPropelDataSetWriter( | ||
| 1490 | $this->getProductBundleFacade(), | ||
| 1491 | $this->createProductRepository(), | ||
| 1492 | $this->getStoreFacade(), | ||
| 1493 | $this->getStockFacade(), | ||
| 1494 | ); | ||
| 1495 | } | ||
| 1496 | |||
| 1497 | /** | ||
| 1498 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1499 | */ | ||
| 1500 | public function createCombinedProductAbstractStorePropelDataSetWriter(): DataSetWriterInterface | ||
| 1501 |     { | ||
| 1502 | return new CombinedProductAbstractStorePropelDataSetWriter(); | ||
| 1503 | } | ||
| 1504 | |||
| 1505 | /** | ||
| 1506 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1507 | */ | ||
| 1508 | public function createCombinedProductAbstractPropelDataSetWriter(): DataSetWriterInterface | ||
| 1509 |     { | ||
| 1510 | return new CombinedProductAbstractPropelDataSetWriter( | ||
| 1511 | $this->createProductRepository(), | ||
| 1512 | ); | ||
| 1513 | } | ||
| 1514 | |||
| 1515 | /** | ||
| 1516 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1517 | */ | ||
| 1518 | public function createCombinedProductConcretePropelDataSetWriter(): DataSetWriterInterface | ||
| 1519 |     { | ||
| 1520 | return new CombinedProductConcretePropelDataSetWriter( | ||
| 1521 | $this->createProductRepository(), | ||
| 1522 | ); | ||
| 1523 | } | ||
| 1524 | |||
| 1525 | /** | ||
| 1526 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1527 | * | ||
| 1528 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1529 | */ | ||
| 1530 | public function createCombinedProductPriceImporter( | ||
| 1531 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1532 |     ): DataImporterInterface { | ||
| 1533 | $dataImporter = $this->getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1534 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1535 | ); | ||
| 1536 | |||
| 1537 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CombinedProductPriceHydratorStep::BULK_SIZE); | ||
| 1538 | $dataSetStepBroker | ||
| 1539 | ->addStep(new CombinedProductPriceHydratorStep( | ||
| 1540 | $this->getPriceProductFacade(), | ||
| 1541 | $this->getUtilEncodingService(), | ||
| 1542 | )); | ||
| 1543 | |||
| 1544 | $dataImporter->setDataSetCondition($this->createCombinedProductPriceMandatoryColumnCondition()); | ||
| 1545 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1546 | $dataImporter->setDataSetWriter($this->createCombinedProductPriceDataSetWriters()); | ||
| 1547 | |||
| 1548 | return $dataImporter; | ||
| 1549 | } | ||
| 1550 | |||
| 1551 | /** | ||
| 1552 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1553 | */ | ||
| 1554 | protected function createCombinedProductPriceMandatoryColumnCondition(): DataSetConditionInterface | ||
| 1555 |     { | ||
| 1556 | return new CombinedProductPriceMandatoryColumnCondition(); | ||
| 1557 | } | ||
| 1558 | |||
| 1559 | /** | ||
| 1560 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1561 | */ | ||
| 1562 | protected function createCombinedProductPriceDataSetWriters(): DataSetWriterInterface | ||
| 1563 |     { | ||
| 1564 | return new DataSetWriterCollection($this->createCombinedProductPriceDataSetWriterPlugins()); | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | /** | ||
| 1568 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1569 | */ | ||
| 1570 | protected function createCombinedProductPriceDataSetWriterPlugins(): array | ||
| 1571 |     { | ||
| 1572 | return [ | ||
| 1573 | new CombinedProductPricePropelWriterPlugin(), | ||
| 1574 | ]; | ||
| 1575 | } | ||
| 1576 | |||
| 1577 | /** | ||
| 1578 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1579 | * | ||
| 1580 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1581 | */ | ||
| 1582 | public function createCombinedProductImageImporter( | ||
| 1606 | } | ||
| 1607 | |||
| 1608 | /** | ||
| 1609 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1610 | */ | ||
| 1611 | protected function createCombinedProductImageMandatoryColumnCondition(): DataSetConditionInterface | ||
| 1612 |     { | ||
| 1613 | return new CombinedProductImageMandatoryColumnCondition(); | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | /** | ||
| 1617 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1618 | */ | ||
| 1619 | protected function createCombinedProductImageDataSetWriters(): DataSetWriterInterface | ||
| 1620 |     { | ||
| 1621 | return new DataSetWriterCollection($this->createCombinedProductImageDataSetWriterPlugins()); | ||
| 1622 | } | ||
| 1623 | |||
| 1624 | /** | ||
| 1625 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1626 | */ | ||
| 1627 | protected function createCombinedProductImageDataSetWriterPlugins(): array | ||
| 1628 |     { | ||
| 1629 | return [ | ||
| 1630 | new CombinedProductImagePropelWriterPlugin(), | ||
| 1631 | ]; | ||
| 1632 | } | ||
| 1633 | |||
| 1634 | /** | ||
| 1635 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1636 | * | ||
| 1637 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1638 | */ | ||
| 1639 | public function createCombinedProductStockImporter( | ||
| 1640 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1641 |     ): DataImporterInterface { | ||
| 1642 | $dataImporter = $this->getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1643 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1644 | ); | ||
| 1645 | |||
| 1646 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CombinedProductStockHydratorStep::BULK_SIZE); | ||
| 1647 | $dataSetStepBroker | ||
| 1648 | ->addStep(new CombinedProductStockHydratorStep()); | ||
| 1649 | |||
| 1650 | $dataImporter->setDataSetCondition($this->createCombinedProductStockMandatoryColumnCondition()); | ||
| 1651 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1652 | $dataImporter->setDataSetWriter($this->createCombinedProductStockDataSetWriters()); | ||
| 1653 | |||
| 1654 | return $dataImporter; | ||
| 1655 | } | ||
| 1656 | |||
| 1657 | /** | ||
| 1658 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1659 | */ | ||
| 1660 | protected function createCombinedProductStockMandatoryColumnCondition(): DataSetConditionInterface | ||
| 1661 |     { | ||
| 1662 | return new CombinedProductStockMandatoryColumnCondition(); | ||
| 1663 | } | ||
| 1664 | |||
| 1665 | /** | ||
| 1666 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1667 | */ | ||
| 1668 | protected function createCombinedProductStockDataSetWriters(): DataSetWriterInterface | ||
| 1669 |     { | ||
| 1670 | return new DataSetWriterCollection($this->createCombinedProductStockDataSetWriterPlugins()); | ||
| 1671 | } | ||
| 1672 | |||
| 1673 | /** | ||
| 1674 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1675 | */ | ||
| 1676 | protected function createCombinedProductStockDataSetWriterPlugins(): array | ||
| 1677 |     { | ||
| 1678 | return [ | ||
| 1679 | new CombinedProductStockPropelWriterPlugin(), | ||
| 1680 | ]; | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | /** | ||
| 1684 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1685 | * | ||
| 1686 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1687 | */ | ||
| 1688 | public function createCombinedProductAbstractStoreImporter( | ||
| 1689 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1690 |     ): DataImporterInterface { | ||
| 1691 | $dataImporter = $this->getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1692 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1693 | ); | ||
| 1694 | |||
| 1695 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CombinedProductAbstractStoreHydratorStep::BULK_SIZE); | ||
| 1696 | $dataSetStepBroker->addStep(new CombinedProductAbstractStoreHydratorStep()); | ||
| 1697 | |||
| 1698 | $dataImporter->setDataSetCondition($this->createCombinedProductAbstractStoreMandatoryColumnCondition()); | ||
| 1699 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1700 | $dataImporter->setDataSetWriter($this->createCombinedProductAbstractStoreDataSetWriters()); | ||
| 1701 | |||
| 1702 | return $dataImporter; | ||
| 1703 | } | ||
| 1704 | |||
| 1705 | /** | ||
| 1706 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1707 | */ | ||
| 1708 | protected function createCombinedProductAbstractStoreMandatoryColumnCondition(): DataSetConditionInterface | ||
| 1709 |     { | ||
| 1710 | return new CombinedProductAbstractStoreMandatoryColumnCondition(); | ||
| 1711 | } | ||
| 1712 | |||
| 1713 | /** | ||
| 1714 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1715 | */ | ||
| 1716 | protected function createCombinedProductAbstractStoreDataSetWriters(): DataSetWriterInterface | ||
| 1717 |     { | ||
| 1718 | return new DataSetWriterCollection($this->createCombinedProductAbstractStoreDataSetWriterPlugins()); | ||
| 1719 | } | ||
| 1720 | |||
| 1721 | /** | ||
| 1722 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1723 | */ | ||
| 1724 | protected function createCombinedProductAbstractStoreDataSetWriterPlugins(): array | ||
| 1725 |     { | ||
| 1726 | return [ | ||
| 1727 | new CombinedProductAbstractStorePropelWriterPlugin(), | ||
| 1728 | ]; | ||
| 1729 | } | ||
| 1730 | |||
| 1731 | /** | ||
| 1732 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1733 | * | ||
| 1734 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1735 | */ | ||
| 1736 | public function createCombinedProductAbstractImporter( | ||
| 1737 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1738 |     ): DataImporterInterface { | ||
| 1739 | $dataImporter = $this->getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1740 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1741 | ); | ||
| 1742 | |||
| 1743 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CombinedProductAbstractHydratorStep::BULK_SIZE); | ||
| 1744 | $dataSetStepBroker | ||
| 1745 | ->addStep($this->createProductAbstractCheckExistenceStep()) | ||
| 1746 | ->addStep($this->createAddLocalesStep()) | ||
| 1747 | ->addStep($this->createAddCategoryKeysStep()) | ||
| 1748 | ->addStep($this->createTaxSetNameToIdTaxSetStep(CombinedProductAbstractHydratorStep::COLUMN_TAX_SET_NAME)) | ||
| 1749 | ->addStep($this->createCombinedAttributesExtractorStep()) | ||
| 1750 | ->addStep($this->createCombinedProductLocalizedAttributesExtractorStep([ | ||
| 1751 | CombinedProductAbstractHydratorStep::COLUMN_NAME, | ||
| 1752 | CombinedProductAbstractHydratorStep::COLUMN_URL, | ||
| 1753 | CombinedProductAbstractHydratorStep::COLUMN_DESCRIPTION, | ||
| 1754 | CombinedProductAbstractHydratorStep::COLUMN_META_TITLE, | ||
| 1755 | CombinedProductAbstractHydratorStep::COLUMN_META_DESCRIPTION, | ||
| 1756 | CombinedProductAbstractHydratorStep::COLUMN_META_KEYWORDS, | ||
| 1757 | ])) | ||
| 1758 | ->addStep(new CombinedProductAbstractHydratorStep()); | ||
| 1759 | |||
| 1760 | $dataImporter->setDataSetCondition($this->createCombinedProductAbstractTypeDataSetCondition()); | ||
| 1761 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1762 | $dataImporter->setDataSetWriter($this->createCombinedProductAbstractDataSetWriters()); | ||
| 1763 | |||
| 1764 | return $dataImporter; | ||
| 1765 | } | ||
| 1766 | |||
| 1767 | /** | ||
| 1768 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1769 | */ | ||
| 1770 | protected function createCombinedProductAbstractTypeDataSetCondition(): DataSetConditionInterface | ||
| 1771 |     { | ||
| 1772 | return new CombinedProductAbstractTypeDataSetCondition(); | ||
| 1773 | } | ||
| 1774 | |||
| 1775 | /** | ||
| 1776 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1777 | */ | ||
| 1778 | protected function createCombinedProductAbstractDataSetWriters(): DataSetWriterInterface | ||
| 1779 |     { | ||
| 1780 | return new DataSetWriterCollection($this->createCombinedProductAbstractDataSetWriterPlugins()); | ||
| 1781 | } | ||
| 1782 | |||
| 1783 | /** | ||
| 1784 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1785 | */ | ||
| 1786 | protected function createCombinedProductAbstractDataSetWriterPlugins(): array | ||
| 1787 |     { | ||
| 1788 | return [ | ||
| 1789 | new CombinedProductAbstractPropelWriterPlugin(), | ||
| 1790 | ]; | ||
| 1791 | } | ||
| 1792 | |||
| 1793 | /** | ||
| 1794 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1795 | * | ||
| 1796 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1797 | */ | ||
| 1798 | public function createCombinedProductConcreteImporter( | ||
| 1799 | DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer, | ||
| 1800 |     ): DataImporterInterface { | ||
| 1801 | $dataImporter = $this->getConditionalCsvDataImporterWriterAwareFromConfig( | ||
| 1802 | $this->getConfig()->buildImporterConfigurationByDataImportConfigAction($dataImportConfigurationActionTransfer), | ||
| 1803 | ); | ||
| 1804 | |||
| 1805 | $dataSetStepBroker = $this->createTransactionAwareDataSetStepBroker(CombinedProductConcreteHydratorStep::BULK_SIZE); | ||
| 1806 | $dataSetStepBroker | ||
| 1807 | ->addStep($this->createProductConcreteCheckExistenceStep()) | ||
| 1808 | ->addStep($this->createAddLocalesStep()) | ||
| 1809 | ->addStep($this->createCombinedAttributesExtractorStep()) | ||
| 1810 | ->addStep($this->createProductConcreteAttributesUniqueCheckStep()) | ||
| 1811 | ->addStep($this->createCombinedProductLocalizedAttributesExtractorStep([ | ||
| 1812 | CombinedProductConcreteHydratorStep::COLUMN_NAME, | ||
| 1813 | CombinedProductConcreteHydratorStep::COLUMN_DESCRIPTION, | ||
| 1814 | CombinedProductConcreteHydratorStep::COLUMN_IS_SEARCHABLE, | ||
| 1815 | ])) | ||
| 1816 | ->addStep(new CombinedProductConcreteHydratorStep( | ||
| 1817 | $this->createProductRepository(), | ||
| 1818 | )); | ||
| 1819 | |||
| 1820 | $dataImporter->setDataSetCondition($this->createCombinedProductConcreteTypeDataSetCondition()); | ||
| 1821 | $dataImporter->addDataSetStepBroker($dataSetStepBroker); | ||
| 1822 | $dataImporter->setDataSetWriter($this->createCombinedProductConcreteDataSetWriters()); | ||
| 1823 | |||
| 1824 | return $dataImporter; | ||
| 1825 | } | ||
| 1826 | |||
| 1827 | /** | ||
| 1828 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1829 | */ | ||
| 1830 | protected function createCombinedProductConcreteTypeDataSetCondition(): DataSetConditionInterface | ||
| 1831 |     { | ||
| 1832 | return new CombinedProductConcreteTypeDataSetCondition(); | ||
| 1833 | } | ||
| 1834 | |||
| 1835 | /** | ||
| 1836 | * @return \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetWriterInterface | ||
| 1837 | */ | ||
| 1838 | protected function createCombinedProductConcreteDataSetWriters(): DataSetWriterInterface | ||
| 1839 |     { | ||
| 1840 | return new DataSetWriterCollection($this->createCombinedProductConcreteDataSetWriterPlugins()); | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | /** | ||
| 1844 | * @return array<\Spryker\Zed\DataImportExtension\Dependency\Plugin\DataSetWriterPluginInterface> | ||
| 1845 | */ | ||
| 1846 | protected function createCombinedProductConcreteDataSetWriterPlugins(): array | ||
| 1847 |     { | ||
| 1848 | return [ | ||
| 1849 | new CombinedProductConcretePropelWriterPlugin(), | ||
| 1850 | ]; | ||
| 1851 | } | ||
| 1852 | |||
| 1853 | /** | ||
| 1854 | * @param \Generated\Shared\Transfer\DataImportConfigurationActionTransfer $dataImportConfigurationActionTransfer | ||
| 1855 | * | ||
| 1856 | * @return \Spryker\Zed\DataImport\Business\Model\DataImporterInterface | ||
| 1857 | */ | ||
| 1858 | public function createCombinedProductGroupImporter( | ||
| 1873 | } | ||
| 1874 | |||
| 1875 | /** | ||
| 1876 | * @return \Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface | ||
| 1877 | */ | ||
| 1878 | protected function createCombinedProductGroupMandatoryColumnCondition(): DataSetConditionInterface | ||
| 1879 |     { | ||
| 1880 | return new CombinedProductGroupMandatoryColumnCondition(); | ||
| 1881 | } | ||
| 1882 | |||
| 1883 | /** | ||
| 1884 | * @return \Spryker\Zed\MerchantUser\Business\MerchantUserFacadeInterface | ||
| 1885 | */ | ||
| 1886 | public function getMerchantUserFacade(): MerchantUserFacadeInterface | ||
| 1887 |     { | ||
| 1888 | return $this->getProvidedDependency(DataImportDependencyProvider::FACADE_MERCHANT_USER); | ||
| 1889 | } | ||
| 1890 | } | ||
| 1891 |