Skip to content

Commit ddfc960

Browse files
author
Leonid Poluyanov
committed
MAGETWO-50415: Grouped product has no products in sample data
1 parent f9ba6e8 commit ddfc960

File tree

1 file changed

+21
-38
lines changed
  • app/code/Magento/GroupedProductSampleData/Model

1 file changed

+21
-38
lines changed

app/code/Magento/GroupedProductSampleData/Model/Product.php

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
namespace Magento\GroupedProductSampleData\Model;
77

8-
use Magento\Framework\Setup\SampleData\Context as SampleDataContext;
98
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
9+
use \Magento\Framework\App\ObjectManager;
1010

1111
/**
1212
* Setup grouped product
@@ -21,42 +21,7 @@ class Product extends \Magento\CatalogSampleData\Model\Product
2121
/**
2222
* @var \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks
2323
*/
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;
6025

6126
/**
6227
* @param \Magento\Catalog\Model\Product $product
@@ -65,8 +30,26 @@ public function __construct(
6530
*/
6631
protected function prepareProduct($product, $data)
6732
{
68-
$this->productLinksHelper->initializeLinks($product, $data['grouped_link_data']);
33+
$this->getProductLinksHelper()->initializeLinks($product, $data['grouped_link_data']);
6934
$product->unsetData('grouped_link_data');
7035
return $this;
7136
}
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+
}
7255
}

0 commit comments

Comments
 (0)