Skip to content

Commit d419136

Browse files
author
Yaroslav Onischenko
committed
Merge remote-tracking branch 'origin/MAGETWO-50415' into develop
2 parents 7f196de + ddfc960 commit d419136

File tree

1 file changed

+33
-29
lines changed
  • app/code/Magento/GroupedProductSampleData/Model

1 file changed

+33
-29
lines changed

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

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

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

1011
/**
1112
* Setup grouped product
@@ -18,34 +19,37 @@ class Product extends \Magento\CatalogSampleData\Model\Product
1819
protected $productType = \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE;
1920

2021
/**
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
3023
*/
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+
}
5054
}
5155
}

0 commit comments

Comments
 (0)