5
5
*/
6
6
namespace Magento \ConfigurableSampleData \Model ;
7
7
8
- use Magento \Framework \App \Filesystem \DirectoryList ;
8
+ use Magento \Framework \Component \ComponentRegistrar ;
9
+ use Magento \Framework \Filesystem \Directory \ReadFactory ;
9
10
use Magento \ImportExport \Model \Import ;
10
11
use Magento \ImportExport \Model \Import \ErrorProcessing \ProcessingErrorAggregatorInterface ;
11
12
@@ -25,34 +26,42 @@ class Product
25
26
private $ csvSourceFactory ;
26
27
27
28
/**
28
- * @var \Magento\Framework\Filesystem
29
+ * @var \Magento\Framework\Filesystem\Directory\ReadFactory
29
30
*/
30
- private $ filesystem ;
31
+ private $ readFactory ;
31
32
32
33
/**
33
34
* @var \Magento\Indexer\Model\Indexer\CollectionFactory
34
35
*/
35
36
private $ indexerCollectionFactory ;
36
37
38
+ /**
39
+ * @var \Magento\Framework\Component\ComponentRegistrar
40
+ */
41
+ private $ componentRegistrar ;
42
+
37
43
/**
38
44
* @param \Magento\Eav\Model\Config $eavConfig
39
45
* @param \Magento\ImportExport\Model\Import $importModel
40
46
* @param \Magento\ImportExport\Model\Import\Source\CsvFactory $csvSourceFactory
41
47
* @param \Magento\Indexer\Model\Indexer\CollectionFactory $indexerCollectionFactory
42
- * @param \Magento\Framework\Filesystem $filesystem
48
+ * @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
49
+ * @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
43
50
*/
44
51
public function __construct (
45
52
\Magento \Eav \Model \Config $ eavConfig ,
46
53
\Magento \ImportExport \Model \Import $ importModel ,
47
54
\Magento \ImportExport \Model \Import \Source \CsvFactory $ csvSourceFactory ,
48
55
\Magento \Indexer \Model \Indexer \CollectionFactory $ indexerCollectionFactory ,
49
- \Magento \Framework \Filesystem $ filesystem
56
+ \Magento \Framework \Filesystem \Directory \ReadFactory $ readFactory ,
57
+ \Magento \Framework \Component \ComponentRegistrar $ componentRegistrar
50
58
) {
51
59
$ this ->eavConfig = $ eavConfig ;
52
60
$ this ->importModel = $ importModel ;
53
61
$ this ->csvSourceFactory = $ csvSourceFactory ;
54
62
$ this ->indexerCollectionFactory = $ indexerCollectionFactory ;
55
- $ this ->filesystem = $ filesystem ;
63
+ $ this ->filesystem = $ readFactory ;
64
+ $ this ->componentRegistrar = $ componentRegistrar ;
56
65
}
57
66
58
67
/**
@@ -73,14 +82,15 @@ public function install()
73
82
74
83
$ source = $ this ->csvSourceFactory ->create (
75
84
[
76
- 'file ' => 'Magento/ConfigurableSampleData/fixtures/products.csv ' ,
77
- 'directory ' => $ this ->filesystem ->getDirectoryWrite (DirectoryList::MODULES )
85
+ 'file ' => 'fixtures/products.csv ' ,
86
+ 'directory ' => $ this ->readFactory ->create (
87
+ $ this ->componentRegistrar ->getPath (ComponentRegistrar::MODULE , 'Magento_SampleData ' )
88
+ )
78
89
]
79
90
);
80
91
81
92
$ currentPath = getcwd ();
82
- chdir ($ this ->filesystem ->getDirectoryRead (DirectoryList::ROOT )->getAbsolutePath ());
83
-
93
+ chdir (BP );
84
94
$ importModel ->validateSource ($ source );
85
95
$ importModel ->importSource ();
86
96
0 commit comments