|
1 | 1 | <?php
|
2 |
| - |
3 | 2 | /**
|
4 |
| - * Import entity of bundle product type |
5 |
| - * |
6 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
7 | 4 | * See COPYING.txt for license details.
|
8 | 5 | */
|
| 6 | +declare(strict_types=1); |
| 7 | + |
9 | 8 | namespace Magento\BundleImportExport\Model\Import\Product\Type;
|
10 | 9 |
|
11 | 10 | use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
|
|
19 | 18 | use Magento\Store\Model\StoreManagerInterface;
|
20 | 19 |
|
21 | 20 | /**
|
22 |
| - * Class Bundle |
| 21 | + * Import entity of bundle product type |
23 | 22 | *
|
24 |
| - * @package Magento\BundleImportExport\Model\Import\Product\Type |
25 | 23 | * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
|
26 | 24 | */
|
27 | 25 | class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
|
28 | 26 | {
|
| 27 | + /** |
| 28 | + * phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting |
| 29 | + */ |
29 | 30 |
|
30 | 31 | /**
|
31 | 32 | * Delimiter before product option value.
|
@@ -62,6 +63,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
|
62 | 63 | */
|
63 | 64 | const SELECTION_PRICE_TYPE_PERCENT = 1;
|
64 | 65 |
|
| 66 | + /** |
| 67 | + * phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting |
| 68 | + */ |
| 69 | + |
65 | 70 | /**
|
66 | 71 | * Array of cached options.
|
67 | 72 | *
|
@@ -616,6 +621,7 @@ protected function populateInsertOptionValues(array $optionIds): array
|
616 | 621 | if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
|
617 | 622 | && $assoc['parent_id'] == $entityId) {
|
618 | 623 | $option['parent_id'] = $entityId;
|
| 624 | + //phpcs:ignore Magento2.Performance.ForeachArrayMerge |
619 | 625 | $optionValues = array_merge(
|
620 | 626 | $optionValues,
|
621 | 627 | $this->populateOptionValueTemplate($option, $optionId)
|
@@ -675,10 +681,7 @@ private function insertParentChildRelations()
|
675 | 681 | $childIds = [];
|
676 | 682 | foreach ($options as $option) {
|
677 | 683 | foreach ($option['selections'] as $selection) {
|
678 |
| - if (!isset($selection['parent_product_id'])) { |
679 |
| - if (!isset($this->_cachedSkuToProducts[$selection['sku']])) { |
680 |
| - continue; |
681 |
| - } |
| 684 | + if (isset($this->_cachedSkuToProducts[$selection['sku']])) { |
682 | 685 | $childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
|
683 | 686 | }
|
684 | 687 | }
|
@@ -717,6 +720,8 @@ protected function _initAttributes()
|
717 | 720 | }
|
718 | 721 | }
|
719 | 722 | }
|
| 723 | + |
| 724 | + return $this; |
720 | 725 | }
|
721 | 726 |
|
722 | 727 | /**
|
|
0 commit comments