Skip to content

Commit 4866aad

Browse files
author
Leonid Poluyanov
committed
MAGETWO-50450: Bundle product has no products in sample data
1 parent 44af415 commit 4866aad

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\BundleSampleData\Model;
77

8+
use Magento\Framework\Setup\SampleData\Context as SampleDataContext;
89
use Magento\Bundle\Api\Data\OptionInterfaceFactory as OptionFactory;
910
use Magento\Bundle\Api\Data\LinkInterfaceFactory as LinkFactory;
1011
use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepository;
@@ -25,6 +26,37 @@ class Product extends \Magento\CatalogSampleData\Model\Product
2526
*/
2627
private $optionFactory;
2728

29+
/**
30+
* Product constructor.
31+
* @param SampleDataContext $sampleDataContext
32+
* @param \Magento\Catalog\Model\ProductFactory $productFactory
33+
* @param \Magento\Catalog\Model\ConfigFactory $catalogConfig
34+
* @param Product\Converter $converter
35+
* @param \Magento\CatalogSampleData\Model\Product\Gallery $gallery
36+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
37+
* @param \Magento\Eav\Model\Config $eavConfig
38+
*/
39+
public function __construct(
40+
SampleDataContext $sampleDataContext,
41+
\Magento\Catalog\Model\ProductFactory $productFactory,
42+
\Magento\Catalog\Model\ConfigFactory $catalogConfig,
43+
\Magento\BundleSampleData\Model\Product\Converter $converter,
44+
\Magento\CatalogSampleData\Model\Product\Gallery $gallery,
45+
\Magento\Store\Model\StoreManagerInterface $storeManager,
46+
\Magento\Eav\Model\Config $eavConfig
47+
) {
48+
$this->eavConfig = $eavConfig;
49+
parent::__construct(
50+
$sampleDataContext,
51+
$productFactory,
52+
$catalogConfig,
53+
$converter,
54+
$gallery,
55+
$storeManager,
56+
$eavConfig
57+
);
58+
}
59+
2860
/**
2961
* @var LinkFactory
3062
*/
@@ -47,7 +79,6 @@ protected function prepareProduct($product, $data)
4779
$bundleOptionsData = $product->getBundleOptionsData();
4880
$options = [];
4981
foreach ($bundleOptionsData as $key => $optionData) {
50-
5182
$option = $this->getOptionFactory()->create(['data' => $optionData]);
5283
$option->setSku($product->getSku());
5384
$option->setOptionId(null);
@@ -87,7 +118,7 @@ private function getOptionFactory()
87118

88119
if (!($this->optionFactory)) {
89120
return ObjectManager::getInstance()->get(
90-
'\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks'
121+
'\Magento\Bundle\Api\Data\OptionInterfaceFactory'
91122
);
92123
} else {
93124
return $this->optionFactory;
@@ -105,7 +136,7 @@ private function getLinkFactory()
105136

106137
if (!($this->linkFactory)) {
107138
return ObjectManager::getInstance()->get(
108-
'\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks'
139+
'\Magento\Bundle\Api\Data\LinkInterfaceFactory'
109140
);
110141
} else {
111142
return $this->linkFactory;
@@ -123,7 +154,7 @@ private function getProductRepository()
123154

124155
if (!($this->productRepository)) {
125156
return ObjectManager::getInstance()->get(
126-
'\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks'
157+
'\Magento\Catalog\Api\ProductRepositoryInterface'
127158
);
128159
} else {
129160
return $this->productRepository;

0 commit comments

Comments
 (0)