File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed
app/code/Magento/CatalogImportExport Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -222,6 +222,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
222
222
/**
223
223
* Links attribute name-to-link type ID.
224
224
*
225
+ * @deprecated use DI for LinkProcessor class if you want to add additional types
226
+ *
225
227
* @var array
226
228
*/
227
229
protected $ _linkNameToId = [
@@ -882,6 +884,8 @@ public function __construct(
882
884
->get (StockItemImporterInterface::class);
883
885
$ this ->linkProcessor = $ linkProcessor ?? ObjectManager::getInstance ()
884
886
->get (LinkProcessor::class);
887
+ $ this ->linkProcessor ->addNameToIds ($ this ->_linkNameToId );
888
+
885
889
parent ::__construct (
886
890
$ jsonHelper ,
887
891
$ importExportData ,
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ class LinkProcessor
30
30
'_crosssell_ ' => \Magento \Catalog \Model \Product \Link::LINK_TYPE_CROSSSELL ,
31
31
'_upsell_ ' => \Magento \Catalog \Model \Product \Link::LINK_TYPE_UPSELL ,
32
32
];
33
+ /**
34
+ * @var array
35
+ */
36
+ private $ linkNameToId ;
33
37
34
38
/** @var LinkFactory */
35
39
private $ linkFactory ;
@@ -38,21 +42,24 @@ class LinkProcessor
38
42
private $ resourceHelper ;
39
43
40
44
/** @var SkuProcessor */
41
- protected $ skuProcessor ;
45
+ private $ skuProcessor ;
42
46
43
47
/** @var LoggerInterface */
44
- protected $ logger ;
48
+ private $ logger ;
45
49
46
50
public function __construct (
47
51
LinkFactory $ linkFactory ,
48
52
Helper $ resourceHelper ,
49
53
SkuProcessor $ skuProcessor ,
50
- LoggerInterface $ logger
54
+ LoggerInterface $ logger ,
55
+ array $ linkNameToId
51
56
) {
52
57
$ this ->linkFactory = $ linkFactory ;
53
58
$ this ->resourceHelper = $ resourceHelper ;
54
59
$ this ->skuProcessor = $ skuProcessor ;
55
60
$ this ->logger = $ logger ;
61
+
62
+ $ this ->linkNameToId = $ linkNameToId ;
56
63
}
57
64
58
65
/**
@@ -92,6 +99,11 @@ public function saveLinks(
92
99
return $ this ;
93
100
}
94
101
102
+ public function addNameToIds ($ nameToIds )
103
+ {
104
+ $ this ->linkNameToId = array_merge ($ nameToIds , $ this ->linkNameToId );
105
+ }
106
+
95
107
/**
96
108
* Processes link bunches
97
109
*
Original file line number Diff line number Diff line change 28
28
</argument >
29
29
</arguments >
30
30
</type >
31
+ <type name =" Magento\CatalogImportExport\Model\Import\Product\LinkProcessor" >
32
+ <arguments >
33
+ <argument name =" linkNameToId" xsi : type =" array" >
34
+ <item name =" _related_" xsi : type =" const" >Magento\Catalog\Model\Product\Link::LINK_TYPE_RELATED</item >
35
+ <item name =" _crosssell_" xsi : type =" const" >Magento\Catalog\Model\Product\Link::LINK_TYPE_CROSSSELL</item >
36
+ <item name =" _upsell_" xsi : type =" const" >Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL</item >
37
+ </argument >
38
+ </arguments >
39
+ </type >
31
40
</config >
You can’t perform that action at this time.
0 commit comments