5
5
*/
6
6
namespace Magento \GroupedProductSampleData \Model ;
7
7
8
- use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
8
+ use Magento \Catalog \Model \Product \Initialization \Helper \ProductLinks ;
9
+ use \Magento \Framework \App \ObjectManager ;
9
10
10
11
/**
11
12
* Setup grouped product
@@ -18,34 +19,37 @@ class Product extends \Magento\CatalogSampleData\Model\Product
18
19
protected $ productType = \Magento \GroupedProduct \Model \Product \Type \Grouped::TYPE_CODE ;
19
20
20
21
/**
21
- * Product constructor.
22
- * @param SampleDataContext $sampleDataContext
23
- * @param \Magento\Catalog\Model\ProductFactory $productFactory
24
- * @param \Magento\Catalog\Model\ConfigFactory $catalogConfig
25
- * @param \Magento\GroupedProductSampleData\Model\Product\Converter $converter
26
- * @param \Magento\Framework\Setup\SampleData\FixtureManager $fixtureManager
27
- * @param \Magento\CatalogSampleData\Model\Product\Gallery $gallery
28
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
29
- * @param \Magento\Eav\Model\Config $eavConfig
22
+ * @var \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks
30
23
*/
31
- public function __construct (
32
- SampleDataContext $ sampleDataContext ,
33
- \Magento \Catalog \Model \ProductFactory $ productFactory ,
34
- \Magento \Catalog \Model \ConfigFactory $ catalogConfig ,
35
- \Magento \GroupedProductSampleData \Model \Product \Converter $ converter ,
36
- \Magento \Framework \Setup \SampleData \FixtureManager $ fixtureManager ,
37
- \Magento \CatalogSampleData \Model \Product \Gallery $ gallery ,
38
- \Magento \Store \Model \StoreManagerInterface $ storeManager ,
39
- \Magento \Eav \Model \Config $ eavConfig
40
- ) {
41
- parent ::__construct (
42
- $ sampleDataContext ,
43
- $ productFactory ,
44
- $ catalogConfig ,
45
- $ converter ,
46
- $ gallery ,
47
- $ storeManager ,
48
- $ eavConfig
49
- );
24
+ private $ productLinksHelper ;
25
+
26
+ /**
27
+ * @param \Magento\Catalog\Model\Product $product
28
+ * @param array $data
29
+ * @return $this
30
+ */
31
+ protected function prepareProduct ($ product , $ data )
32
+ {
33
+ $ this ->getProductLinksHelper ()->initializeLinks ($ product , $ data ['grouped_link_data ' ]);
34
+ $ product ->unsetData ('grouped_link_data ' );
35
+ return $ this ;
36
+ }
37
+
38
+ /**
39
+ * Get product links helper
40
+ *
41
+ * @deprecated
42
+ * @return \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks
43
+ */
44
+ private function getProductLinksHelper ()
45
+ {
46
+
47
+ if (!($ this ->productLinksHelper )) {
48
+ return ObjectManager::getInstance ()->get (
49
+ '\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks '
50
+ );
51
+ } else {
52
+ return $ this ->productLinksHelper ;
53
+ }
50
54
}
51
55
}
0 commit comments