5
5
*/
6
6
namespace Magento \GroupedProductSampleData \Model ;
7
7
8
- use Magento \Framework \Setup \SampleData \Context as SampleDataContext ;
9
8
use Magento \Catalog \Model \Product \Initialization \Helper \ProductLinks ;
9
+ use \Magento \Framework \App \ObjectManager ;
10
10
11
11
/**
12
12
* Setup grouped product
@@ -21,42 +21,7 @@ class Product extends \Magento\CatalogSampleData\Model\Product
21
21
/**
22
22
* @var \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks
23
23
*/
24
- protected $ productLinksHelper ;
25
-
26
- /**
27
- * Product constructor.
28
- * @param SampleDataContext $sampleDataContext
29
- * @param \Magento\Catalog\Model\ProductFactory $productFactory
30
- * @param \Magento\Catalog\Model\ConfigFactory $catalogConfig
31
- * @param \Magento\GroupedProductSampleData\Model\Product\Converter $converter
32
- * @param \Magento\Framework\Setup\SampleData\FixtureManager $fixtureManager
33
- * @param \Magento\CatalogSampleData\Model\Product\Gallery $gallery
34
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
35
- * @param \Magento\Eav\Model\Config $eavConfig
36
- * @param \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinksHelper
37
- */
38
- public function __construct (
39
- SampleDataContext $ sampleDataContext ,
40
- \Magento \Catalog \Model \ProductFactory $ productFactory ,
41
- \Magento \Catalog \Model \ConfigFactory $ catalogConfig ,
42
- \Magento \GroupedProductSampleData \Model \Product \Converter $ converter ,
43
- \Magento \Framework \Setup \SampleData \FixtureManager $ fixtureManager ,
44
- \Magento \CatalogSampleData \Model \Product \Gallery $ gallery ,
45
- \Magento \Store \Model \StoreManagerInterface $ storeManager ,
46
- \Magento \Eav \Model \Config $ eavConfig ,
47
- \Magento \Catalog \Model \Product \Initialization \Helper \ProductLinks $ productLinksHelper
48
- ) {
49
- parent ::__construct (
50
- $ sampleDataContext ,
51
- $ productFactory ,
52
- $ catalogConfig ,
53
- $ converter ,
54
- $ gallery ,
55
- $ storeManager ,
56
- $ eavConfig
57
- );
58
- $ this ->productLinksHelper = $ productLinksHelper ;
59
- }
24
+ private $ productLinksHelper ;
60
25
61
26
/**
62
27
* @param \Magento\Catalog\Model\Product $product
@@ -65,8 +30,26 @@ public function __construct(
65
30
*/
66
31
protected function prepareProduct ($ product , $ data )
67
32
{
68
- $ this ->productLinksHelper ->initializeLinks ($ product , $ data ['grouped_link_data ' ]);
33
+ $ this ->getProductLinksHelper () ->initializeLinks ($ product , $ data ['grouped_link_data ' ]);
69
34
$ product ->unsetData ('grouped_link_data ' );
70
35
return $ this ;
71
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
+ }
54
+ }
72
55
}
0 commit comments