Skip to content

Commit 6169054

Browse files
author
Sergii Kovalenko
authored
Merge pull request #2506 from magento-trigger/MAGETWO-90957
[trigger] MAGETWO-90957: Product generation fails on medium profile
2 parents 98e4a6e + 341060c commit 6169054

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

dev/tests/integration/testsuite/Magento/Setup/Model/FixtureGenerator/ProductGeneratorTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
use Magento\Catalog\Api\ProductRepositoryInterface;
1010
use Magento\Framework\Indexer\IndexerRegistry;
1111
use Magento\Indexer\Model\Config;
12+
use Magento\Store\Model\WebsiteRepository;
1213
use Magento\TestFramework\Helper\Bootstrap;
1314

1415
/**
1516
* @magentoAppArea adminhtml
1617
* @magentoDataFixture Magento/Catalog/_files/category.php
18+
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
1719
*/
1820
class ProductGeneratorTest extends \PHPUnit\Framework\TestCase
1921
{
@@ -37,6 +39,11 @@ class ProductGeneratorTest extends \PHPUnit\Framework\TestCase
3739
*/
3840
private $indexersState = [];
3941

42+
/**
43+
* @var WebsiteRepository
44+
*/
45+
private $websiteRepository;
46+
4047
/**
4148
* @return void
4249
*/
@@ -45,7 +52,7 @@ protected function setUp()
4552
$this->objectManager = Bootstrap::getObjectManager();
4653
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
4754
$this->productGenerator = $this->objectManager->get(ProductGenerator::class);
48-
55+
$this->websiteRepository = $this->objectManager->get(WebsiteRepository::class);
4956
$indexerRegistry = $this->objectManager->get(IndexerRegistry::class);
5057
$indexerListIds = $this->objectManager->get(Config::class)->getIndexers();
5158

@@ -79,6 +86,7 @@ public function testProductGeneration()
7986
$price = 7.99;
8087
$url = 'simple-product-url';
8188
$categoryId = 333;
89+
$secondWebsiteId = $this->websiteRepository->get('test')->getId();
8290

8391
$fixtureMap = [
8492
'name' => function () use ($name) {
@@ -96,6 +104,9 @@ public function testProductGeneration()
96104
'category_ids' => function () use ($categoryId) {
97105
return $categoryId;
98106
},
107+
'website_ids' => function () use ($secondWebsiteId) {
108+
return [1, $secondWebsiteId];
109+
}
99110
];
100111
$this->productGenerator->generate(1, $fixtureMap);
101112

setup/src/Magento/Setup/Model/FixtureGenerator/ProductGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function generate($products, $fixtureMap)
171171
],
172172
];
173173
$websiteIdsFixtures = $fixtureMap['website_ids'](1, 0);
174-
if ((is_array($websiteIdsFixtures) && count($websiteIdsFixtures) === 1) || $websiteIdsFixtures != null) {
174+
if (is_array($websiteIdsFixtures) && count($websiteIdsFixtures) === 1) {
175175
// Get website id from fixture in case when one site is assigned per product
176176
$customTableMap['catalog_product_website'] = [
177177
'fields' => [

0 commit comments

Comments
 (0)