Skip to content

Commit 7cb6736

Browse files
author
Anna Bukatar
committed
ACP2E-779: Configurable products can be associated with the grouped products during product import
1 parent 96faea7 commit 7cb6736

File tree

1 file changed

+23
-3
lines changed
  • app/code/Magento/GroupedImportExport/Model/Import/Product/Type

1 file changed

+23
-3
lines changed

app/code/Magento/GroupedImportExport/Model/Import/Product/Type/Grouped.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88
namespace Magento\GroupedImportExport\Model\Import\Product\Type;
99

10+
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
1011
use Magento\CatalogImportExport\Model\Import\Product;
12+
use Magento\Framework\App\ObjectManager;
1113
use Magento\ImportExport\Model\Import;
1214

1315
class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType
@@ -29,6 +31,16 @@ class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abs
2931
*/
3032
protected $links;
3133

34+
/**
35+
* @var ConfigInterface
36+
*/
37+
protected $config;
38+
39+
/**
40+
* @var string[]
41+
*/
42+
private $allowedProductTypes;
43+
3244
/**
3345
* Product entity identifier field
3446
*
@@ -42,15 +54,19 @@ class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abs
4254
* @param \Magento\Framework\App\ResourceConnection $resource
4355
* @param array $params
4456
* @param Grouped\Links $links
57+
* @param ConfigInterface|null $config
4558
*/
4659
public function __construct(
4760
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFac,
4861
\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $prodAttrColFac,
4962
\Magento\Framework\App\ResourceConnection $resource,
5063
array $params,
51-
Grouped\Links $links
64+
Grouped\Links $links,
65+
ConfigInterface $config = null
5266
) {
5367
$this->links = $links;
68+
$this->config = $config ?: ObjectManager::getInstance()->get(ConfigInterface::class);
69+
$this->allowedProductTypes = $this->config->getComposableTypes();
5470
parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params);
5571
}
5672

@@ -90,9 +106,13 @@ public function saveData()
90106
++$position;
91107
$associatedSkuAndQty = explode(self::SKU_QTY_DELIMITER, $associatedSkuAndQty);
92108
$associatedSku = isset($associatedSkuAndQty[0]) ? strtolower(trim($associatedSkuAndQty[0])) : null;
93-
if (isset($newSku[$associatedSku])) {
109+
if (isset($newSku[$associatedSku]) &&
110+
in_array($newSku[$associatedSku]['type_id'], $this->allowedProductTypes)
111+
) {
94112
$linkedProductId = $newSku[$associatedSku][$this->getProductEntityIdentifierField()];
95-
} elseif (isset($oldSku[$associatedSku])) {
113+
} elseif (isset($oldSku[$associatedSku]) &&
114+
in_array($newSku[$associatedSku]['type_id'], $this->allowedProductTypes)
115+
) {
96116
$linkedProductId = $oldSku[$associatedSku][$this->getProductEntityIdentifierField()];
97117
} else {
98118
continue;

0 commit comments

Comments
 (0)