7
7
*/
8
8
namespace Magento \GroupedImportExport \Model \Import \Product \Type ;
9
9
10
+ use Magento \Catalog \Model \ProductTypes \ConfigInterface ;
10
11
use Magento \CatalogImportExport \Model \Import \Product ;
12
+ use Magento \Framework \App \ObjectManager ;
11
13
use Magento \ImportExport \Model \Import ;
12
14
13
15
class Grouped extends \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType
@@ -29,6 +31,16 @@ class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abs
29
31
*/
30
32
protected $ links ;
31
33
34
+ /**
35
+ * @var ConfigInterface
36
+ */
37
+ protected $ config ;
38
+
39
+ /**
40
+ * @var string[]
41
+ */
42
+ private $ allowedProductTypes ;
43
+
32
44
/**
33
45
* Product entity identifier field
34
46
*
@@ -42,15 +54,19 @@ class Grouped extends \Magento\CatalogImportExport\Model\Import\Product\Type\Abs
42
54
* @param \Magento\Framework\App\ResourceConnection $resource
43
55
* @param array $params
44
56
* @param Grouped\Links $links
57
+ * @param ConfigInterface|null $config
45
58
*/
46
59
public function __construct (
47
60
\Magento \Eav \Model \ResourceModel \Entity \Attribute \Set \CollectionFactory $ attrSetColFac ,
48
61
\Magento \Catalog \Model \ResourceModel \Product \Attribute \CollectionFactory $ prodAttrColFac ,
49
62
\Magento \Framework \App \ResourceConnection $ resource ,
50
63
array $ params ,
51
- Grouped \Links $ links
64
+ Grouped \Links $ links ,
65
+ ConfigInterface $ config = null
52
66
) {
53
67
$ this ->links = $ links ;
68
+ $ this ->config = $ config ?: ObjectManager::getInstance ()->get (ConfigInterface::class);
69
+ $ this ->allowedProductTypes = $ this ->config ->getComposableTypes ();
54
70
parent ::__construct ($ attrSetColFac , $ prodAttrColFac , $ resource , $ params );
55
71
}
56
72
@@ -90,9 +106,13 @@ public function saveData()
90
106
++$ position ;
91
107
$ associatedSkuAndQty = explode (self ::SKU_QTY_DELIMITER , $ associatedSkuAndQty );
92
108
$ 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
+ ) {
94
112
$ 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
+ ) {
96
116
$ linkedProductId = $ oldSku [$ associatedSku ][$ this ->getProductEntityIdentifierField ()];
97
117
} else {
98
118
continue ;
0 commit comments