Skip to content

Commit e6aa757

Browse files
committed
Merge branch 'ACP2E-1737' of https://github.com/magento-l3/magento2ce into PR-L3-03132023
2 parents 6cee697 + 96c6f24 commit e6aa757

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/CategoryProcessor.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Import\Product;
77

8+
use Magento\Store\Model\Store;
9+
810
/**
911
* @api
1012
* @since 100.0.2
@@ -119,6 +121,7 @@ protected function createCategory($name, $parentId)
119121
$category->setIsActive(true);
120122
$category->setIncludeInMenu(true);
121123
$category->setAttributeSetId($category->getDefaultAttributeSetId());
124+
$category->setStoreId(Store::DEFAULT_STORE_ID);
122125
$category->save();
123126
$this->categoriesCache[$category->getId()] = $category;
124127
return $category->getId();

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/CategoryProcessorTest.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
use Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType;
1414
use Magento\Framework\Exception\AlreadyExistsException;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
16+
use Magento\Store\Model\Store;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use PHPUnit\Framework\TestCase;
1819

1920
class CategoryProcessorTest extends TestCase
2021
{
21-
const PARENT_CATEGORY_ID = 1;
22+
public const PARENT_CATEGORY_ID = 1;
2223

23-
const CHILD_CATEGORY_ID = 2;
24+
public const CHILD_CATEGORY_ID = 2;
2425

25-
const CHILD_CATEGORY_NAME = 'Child';
26+
public const CHILD_CATEGORY_NAME = 'Child';
2627

2728
/**
2829
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
@@ -48,7 +49,7 @@ class CategoryProcessorTest extends TestCase
4849
private $childCategory;
4950

5051
/**
51-
* \Magento\Catalog\Model\Category
52+
* @var \Magento\Catalog\Model\Category
5253
*/
5354
private $parentCategory;
5455

@@ -200,4 +201,19 @@ protected function setPropertyValue(&$object, $property, $value)
200201
$reflectionProperty->setValue($object, $value);
201202
return $object;
202203
}
204+
205+
/**
206+
* @throws \ReflectionException
207+
*/
208+
public function testCategoriesCreatedForGlobalScope()
209+
{
210+
$this->childCategory->expects($this->once())
211+
->method('setStoreId')
212+
->with(Store::DEFAULT_STORE_ID);
213+
214+
$reflection = new \ReflectionClass($this->categoryProcessor);
215+
$createCategoryReflection = $reflection->getMethod('createCategory');
216+
$createCategoryReflection->setAccessible(true);
217+
$createCategoryReflection->invokeArgs($this->categoryProcessor, ['testCategory', 2]);
218+
}
203219
}

0 commit comments

Comments
 (0)