5
5
*/
6
6
namespace Magento \ConfigurableSampleData \Model ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
8
9
use Magento \Framework \Component \ComponentRegistrar ;
9
10
use Magento \Framework \Filesystem \Directory \ReadFactory ;
10
11
use Magento \ImportExport \Model \Import ;
15
16
*/
16
17
class Product
17
18
{
18
- /**
19
- * @var \Magento\ImportExport\Model\Import
20
- */
21
- private $ importModel ;
22
-
23
19
/**
24
20
* @var \Magento\ImportExport\Model\Import\Source\CsvFactory
25
21
*/
@@ -40,37 +36,54 @@ class Product
40
36
*/
41
37
private $ componentRegistrar ;
42
38
39
+ /**
40
+ * @var \Magento\ImportExport\Model\ImportFactory
41
+ */
42
+ private $ importFactory ;
43
+
44
+ /**
45
+ * @var \Magento\Eav\Model\Config
46
+ */
47
+ private $ eavConfig ;
48
+
43
49
/**
44
50
* @param \Magento\Eav\Model\Config $eavConfig
45
- * @param \Magento\ImportExport\Model\ Import $importModel
51
+ * @param Import $importModel
46
52
* @param \Magento\ImportExport\Model\Import\Source\CsvFactory $csvSourceFactory
47
53
* @param \Magento\Indexer\Model\Indexer\CollectionFactory $indexerCollectionFactory
48
54
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
49
55
* @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
56
+ * @param \Magento\ImportExport\Model\ImportFactory|null $importFactory
50
57
*/
51
58
public function __construct (
52
59
\Magento \Eav \Model \Config $ eavConfig ,
53
- \ Magento \ ImportExport \ Model \ Import $ importModel ,
60
+ Import $ importModel ,
54
61
\Magento \ImportExport \Model \Import \Source \CsvFactory $ csvSourceFactory ,
55
62
\Magento \Indexer \Model \Indexer \CollectionFactory $ indexerCollectionFactory ,
56
63
\Magento \Framework \Filesystem \Directory \ReadFactory $ readFactory ,
57
- \Magento \Framework \Component \ComponentRegistrar $ componentRegistrar
64
+ \Magento \Framework \Component \ComponentRegistrar $ componentRegistrar ,
65
+ ?\Magento \ImportExport \Model \ImportFactory $ importFactory = null
58
66
) {
59
67
$ this ->eavConfig = $ eavConfig ;
60
- $ this ->importModel = $ importModel ;
61
68
$ this ->csvSourceFactory = $ csvSourceFactory ;
62
69
$ this ->indexerCollectionFactory = $ indexerCollectionFactory ;
63
70
$ this ->readFactory = $ readFactory ;
64
71
$ this ->componentRegistrar = $ componentRegistrar ;
72
+ $ this ->importFactory = $ importFactory
73
+ ?? ObjectManager::getInstance ()->get (\Magento \ImportExport \Model \ImportFactory::class);
65
74
}
66
75
67
76
/**
68
77
* @inheritdoc
69
78
*/
70
79
public function install ()
71
80
{
81
+ \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::$ attributeCodeToId = [];
82
+ \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::$ commonAttributesCache = [];
83
+ \Magento \CatalogImportExport \Model \Import \Product \Type \AbstractType::$ invAttributesCache = [];
72
84
$ this ->eavConfig ->clear ();
73
- $ importModel = $ this ->importModel ;
85
+ /** @var Import $importModel */
86
+ $ importModel = $ this ->importFactory ->create ();
74
87
$ importModel ->setData (
75
88
[
76
89
'entity ' => 'catalog_product ' ,
0 commit comments