Skip to content

Commit 37078e1

Browse files
committed
MC-35484: Bundle relations is remmoved when prodcuts are re-imported
1 parent c8f56e8 commit 37078e1

File tree

1 file changed

+14
-9
lines changed
  • app/code/Magento/BundleImportExport/Model/Import/Product/Type

1 file changed

+14
-9
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
2-
32
/**
4-
* Import entity of bundle product type
5-
*
63
* Copyright © Magento, Inc. All rights reserved.
74
* See COPYING.txt for license details.
85
*/
6+
declare(strict_types=1);
7+
98
namespace Magento\BundleImportExport\Model\Import\Product\Type;
109

1110
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory as AttributeCollectionFactory;
@@ -19,13 +18,15 @@
1918
use Magento\Store\Model\StoreManagerInterface;
2019

2120
/**
22-
* Class Bundle
21+
* Import entity of bundle product type
2322
*
24-
* @package Magento\BundleImportExport\Model\Import\Product\Type
2523
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2624
*/
2725
class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
2826
{
27+
/**
28+
* phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting
29+
*/
2930

3031
/**
3132
* Delimiter before product option value.
@@ -62,6 +63,10 @@ class Bundle extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abst
6263
*/
6364
const SELECTION_PRICE_TYPE_PERCENT = 1;
6465

66+
/**
67+
* phpcs:enable Magento2.Commenting.ConstantsPHPDocFormatting
68+
*/
69+
6570
/**
6671
* Array of cached options.
6772
*
@@ -616,6 +621,7 @@ protected function populateInsertOptionValues(array $optionIds): array
616621
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
617622
&& $assoc['parent_id'] == $entityId) {
618623
$option['parent_id'] = $entityId;
624+
//phpcs:ignore Magento2.Performance.ForeachArrayMerge
619625
$optionValues = array_merge(
620626
$optionValues,
621627
$this->populateOptionValueTemplate($option, $optionId)
@@ -675,10 +681,7 @@ private function insertParentChildRelations()
675681
$childIds = [];
676682
foreach ($options as $option) {
677683
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']])) {
682685
$childIds[] = $this->_cachedSkuToProducts[$selection['sku']];
683686
}
684687
}
@@ -717,6 +720,8 @@ protected function _initAttributes()
717720
}
718721
}
719722
}
723+
724+
return $this;
720725
}
721726

722727
/**

0 commit comments

Comments
 (0)