5
5
*/
6
6
namespace Magento \SampleData \Module \ConfigurableProduct \Setup ;
7
7
8
- use Magento \SampleData \ Model \ SetupInterface ;
9
- use Magento \Framework \App \ Filesystem \DirectoryList ;
8
+ use Magento \Framework \ Component \ ComponentRegistrar ;
9
+ use Magento \Framework \Filesystem \Directory \ ReadFactory ;
10
10
use Magento \ImportExport \Model \Import ;
11
11
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
12
+ use Magento \SampleData \Model \SetupInterface ;
12
13
13
14
/**
14
15
* Setup configurable product
@@ -31,22 +32,28 @@ class Product implements SetupInterface
31
32
private $ csvSourceFactory ;
32
33
33
34
/**
34
- * @var \Magento\Framework\Filesystem
35
+ * @var \Magento\Framework\Filesystem\Directory\ReadFactory
35
36
*/
36
- private $ filesystem ;
37
+ private $ readFactory ;
37
38
38
39
/**
39
40
* @var \Magento\Indexer\Model\Indexer\CollectionFactory
40
41
*/
41
42
private $ indexerCollectionFactory ;
42
43
44
+ /**
45
+ * @var \Magento\Framework\Component\ComponentRegistrar
46
+ */
47
+ private $ componentRegistrar ;
48
+
43
49
/**
44
50
* @param \Magento\SampleData\Model\Logger $logger
45
51
* @param \Magento\Eav\Model\Config $eavConfig
46
52
* @param \Magento\ImportExport\Model\Import $importModel
47
53
* @param \Magento\ImportExport\Model\Import\Source\CsvFactory $csvSourceFactory
48
54
* @param \Magento\Indexer\Model\Indexer\CollectionFactory $indexerCollectionFactory
49
- * @param \Magento\Framework\Filesystem $filesystem
55
+ * @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
56
+ * @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
50
57
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
51
58
* @codingStandardsIgnoreStart
52
59
*/
@@ -56,14 +63,16 @@ public function __construct(
56
63
\Magento \ImportExport \Model \Import $ importModel ,
57
64
\Magento \ImportExport \Model \Import \Source \CsvFactory $ csvSourceFactory ,
58
65
\Magento \Indexer \Model \Indexer \CollectionFactory $ indexerCollectionFactory ,
59
- \Magento \Framework \Filesystem $ filesystem
66
+ \Magento \Framework \Filesystem \Directory \ReadFactory $ readFactory ,
67
+ \Magento \Framework \Component \ComponentRegistrar $ componentRegistrar
60
68
) {
61
69
$ this ->logger = $ logger ;
62
70
$ this ->eavConfig = $ eavConfig ;
63
71
$ this ->importModel = $ importModel ;
64
72
$ this ->csvSourceFactory = $ csvSourceFactory ;
65
73
$ this ->indexerCollectionFactory = $ indexerCollectionFactory ;
66
- $ this ->filesystem = $ filesystem ;
74
+ $ this ->readFactory = $ readFactory ;
75
+ $ this ->componentRegistrar = $ componentRegistrar ;
67
76
68
77
}
69
78
// @codingStandardsIgnoreEnd
@@ -88,13 +97,15 @@ public function run()
88
97
89
98
$ source = $ this ->csvSourceFactory ->create (
90
99
[
91
- 'file ' => 'Magento/SampleData/fixtures/ConfigurableProduct/import-export_products-img.csv ' ,
92
- 'directory ' => $ this ->filesystem ->getDirectoryWrite (DirectoryList::MODULES )
100
+ 'file ' => 'fixtures/ConfigurableProduct/import-export_products-img.csv ' ,
101
+ 'directory ' => $ this ->readFactory ->create (
102
+ $ this ->componentRegistrar ->getPath (ComponentRegistrar::MODULE , 'Magento_SampleData ' )
103
+ )
93
104
]
94
105
);
95
106
96
107
$ currentPath = getcwd ();
97
- chdir ($ this -> filesystem -> getDirectoryRead (DirectoryList:: ROOT )-> getAbsolutePath () );
108
+ chdir (BP );
98
109
99
110
$ importModel ->validateSource ($ source );
100
111
$ importModel ->importSource ();
0 commit comments