|
6 | 6 | * Copyright © Magento, Inc. All rights reserved.
|
7 | 7 | * See COPYING.txt for license details.
|
8 | 8 | */
|
| 9 | + |
9 | 10 | namespace Magento\BundleImportExport\Model\Import\Product\Type;
|
10 | 11 |
|
11 |
| -use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory; |
12 |
| -use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory; |
13 |
| -use Magento\Framework\App\ObjectManager; |
14 | 12 | use Magento\Bundle\Model\Product\Price as BundlePrice;
|
15 | 13 | use Magento\Catalog\Model\Product\Type\AbstractType;
|
| 14 | +use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory; |
16 | 15 | use Magento\CatalogImportExport\Model\Import\Product;
|
| 16 | +use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory as AttributeSetCollectionFactory; |
| 17 | +use Magento\Framework\App\ObjectManager; |
17 | 18 | use Magento\Framework\App\ResourceConnection;
|
18 | 19 | use Magento\Framework\EntityManager\MetadataPool;
|
19 | 20 | use Magento\Store\Model\StoreManagerInterface;
|
|
26 | 27 | */
|
27 | 28 | class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
|
28 | 29 | {
|
| 30 | + /** |
| 31 | + * phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting |
| 32 | + */ |
29 | 33 |
|
30 | 34 | /**
|
31 | 35 | * Delimiter before product option value.
|
@@ -62,6 +66,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
|
62 | 66 | */
|
63 | 67 | const SELECTION_PRICE_TYPE_PERCENT = 1;
|
64 | 68 |
|
| 69 | + /** |
| 70 | + * phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting |
| 71 | + */ |
| 72 | + |
65 | 73 | /**
|
66 | 74 | * Array of cached options.
|
67 | 75 | *
|
@@ -133,7 +141,7 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
|
133 | 141 | protected $_optionTypeMapping = [
|
134 | 142 | 'dropdown' => 'select',
|
135 | 143 | 'radiobutton' => 'radio',
|
136 |
| - 'checkbox' => 'checkbox', |
| 144 | + 'checkbox' => 'checkbox', |
137 | 145 | 'multiselect' => 'multi',
|
138 | 146 | ];
|
139 | 147 |
|
@@ -543,7 +551,7 @@ protected function populateExistingSelections($existingOptions)
|
543 | 551 | ? $this->_bundleFieldMapping[$origKey]
|
544 | 552 | : $origKey;
|
545 | 553 | if (
|
546 |
| - !isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key]) |
| 554 | + !isset($this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key]) |
547 | 555 | ) {
|
548 | 556 | $this->_cachedOptions[$existingSelection['parent_product_id']][$optionTitle]['selections'][$selectIndex][$key] =
|
549 | 557 | $existingSelection[$origKey];
|
@@ -616,6 +624,7 @@ protected function populateInsertOptionValues(array $optionIds): array
|
616 | 624 | if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
|
617 | 625 | && $assoc['parent_id'] == $entityId) {
|
618 | 626 | $option['parent_id'] = $entityId;
|
| 627 | + //phpcs:ignore Magento2.Performance.ForeachArrayMerge |
619 | 628 | $optionValues = array_merge(
|
620 | 629 | $optionValues,
|
621 | 630 | $this->populateOptionValueTemplate($option, $optionId)
|
@@ -675,10 +684,7 @@ private function insertParentChildRelations()
|
675 | 684 | $childIds = [];
|
676 | 685 | foreach ($options as $option) {
|
677 | 686 | foreach ($option['selections'] as $selection) {
|
678 |
| - if (!isset($selection['parent_product_id'])) { |
679 |
| - if (!isset($this->_cachedSkuToProducts[$selection['sku']])) { |
680 |
| - continue; |
681 |
| - } |
| 687 | + if (isset($this->_cachedSkuToProducts[$selection['sku']])) { |
682 | 688 | $childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
|
683 | 689 | }
|
684 | 690 | }
|
@@ -735,17 +741,19 @@ protected function deleteOptionsAndSelections($productIds)
|
735 | 741 | $optionTable = $this->_resource->getTableName('catalog_product_bundle_option');
|
736 | 742 | $optionValueTable = $this->_resource->getTableName('catalog_product_bundle_option_value');
|
737 | 743 | $selectionTable = $this->_resource->getTableName('catalog_product_bundle_selection');
|
738 |
| - $valuesIds = $this->connection->fetchAssoc($this->connection->select()->from( |
739 |
| - ['bov' => $optionValueTable], |
740 |
| - ['value_id'] |
741 |
| - )->joinLeft( |
742 |
| - ['bo' => $optionTable], |
743 |
| - 'bo.option_id = bov.option_id', |
744 |
| - ['option_id'] |
745 |
| - )->where( |
746 |
| - 'parent_id IN (?)', |
747 |
| - $productIds |
748 |
| - )); |
| 744 | + $valuesIds = $this->connection->fetchAssoc( |
| 745 | + $this->connection->select()->from( |
| 746 | + ['bov' => $optionValueTable], |
| 747 | + ['value_id'] |
| 748 | + )->joinLeft( |
| 749 | + ['bo' => $optionTable], |
| 750 | + 'bo.option_id = bov.option_id', |
| 751 | + ['option_id'] |
| 752 | + )->where( |
| 753 | + 'parent_id IN (?)', |
| 754 | + $productIds |
| 755 | + ) |
| 756 | + ); |
749 | 757 | $this->connection->delete(
|
750 | 758 | $optionValueTable,
|
751 | 759 | $this->connection->quoteInto('value_id IN (?)', array_keys($valuesIds))
|
|
0 commit comments