Skip to content

Commit f50b9da

Browse files
Indrani SonawaneIndrani Sonawane
authored andcommitted
Merge remote-tracking branch '36394/patch-3' into comprs_v2
2 parents 7db7c5e + 3a172d6 commit f50b9da

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

app/code/Magento/Catalog/Model/CategoryRepository.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22
/**
3-
*
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
65
*/
76

87
namespace Magento\Catalog\Model;
@@ -149,7 +148,7 @@ public function save(CategoryInterface $category)
149148
*/
150149
public function get($categoryId, $storeId = null)
151150
{
152-
$cacheKey = $storeId ?? 'all';
151+
$cacheKey = $storeId ?? $this->storeManager->getStore()->getId();
153152
if (!isset($this->instances[$categoryId][$cacheKey])) {
154153
/** @var Category $category */
155154
$category = $this->categoryFactory->create();
@@ -231,7 +230,7 @@ protected function validateCategory(Category $category)
231230
* Lazy loader for the converter.
232231
*
233232
* @return ExtensibleDataObjectConverter
234-
*
233+
* phpcs:disable Magento2.Annotation.MethodAnnotationStructure
235234
* @deprecated 101.0.0
236235
* @see we don't recommend this approach anymore
237236
*/

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66

77
/**
@@ -37,8 +37,6 @@ class Category extends AbstractResource implements ResetAfterRequestInterface
3737
protected $_tree;
3838

3939
/**
40-
* Catalog products table name
41-
*
4240
* @var string
4341
*/
4442
protected $_categoryProductTable;
@@ -49,15 +47,11 @@ class Category extends AbstractResource implements ResetAfterRequestInterface
4947
private $entitiesWhereAttributesIs;
5048

5149
/**
52-
* Id of 'is_active' category attribute
53-
*
5450
* @var int
5551
*/
5652
protected $_isActiveAttributeId = null;
5753

5854
/**
59-
* Id of store
60-
*
6155
* @var int
6256
*/
6357
protected $_storeId = null;
@@ -455,7 +449,7 @@ protected function _saveCategoryProducts($category)
455449
'position' => (int)$position,
456450
];
457451
}
458-
$connection->insertMultiple($this->getCategoryProductTable(), $data);
452+
$connection->insertOnDuplicate($this->getCategoryProductTable(), $data, ['position']);
459453
}
460454

461455
/**

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UpdateCategoryTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2020 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -48,10 +48,9 @@ protected function setUp(): void
4848
public function testUpdateCategoryForDefaultStoreView(array $postData): void
4949
{
5050
$storeId = (int)$this->storeManager->getStore('default')->getId();
51-
$postData = array_merge($postData, ['store_id' => $storeId]);
5251
$responseData = $this->performSaveCategoryRequest($postData);
5352
$this->assertRequestIsSuccessfullyPerformed($responseData);
54-
$category = $this->categoryRepository->get($postData['entity_id'], $postData['store_id']);
53+
$category = $this->categoryRepository->get($postData['entity_id'], $storeId);
5554
unset($postData['use_default']);
5655
unset($postData['use_config']);
5756
foreach ($postData as $key => $value) {

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2012 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -153,7 +153,6 @@ public function testDefaultValueForCategoryUrlPath(): void
153153
$categoryId = 3;
154154
$category = $this->categoryRepository->get($categoryId);
155155
$newUrlPath = 'test_url_path';
156-
$defaultUrlPath = $category->getData('url_path');
157156

158157
// update url_path and check it
159158
$category->setStoreId(1);
@@ -178,7 +177,7 @@ public function testDefaultValueForCategoryUrlPath(): void
178177
MessageInterface::TYPE_SUCCESS
179178
);
180179
$category = $this->categoryRepository->get($categoryId);
181-
$this->assertEquals($defaultUrlPath, $category->getData('url_key'));
180+
$this->assertEquals($newUrlPath, $category->getData('url_key'));
182181
}
183182

184183
/**

dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey()
105105
[
106106
'parent_id' => $category1->getId(),
107107
'name' => 'Category 2',
108-
'url_key' => null,
108+
'url_key' => 'category-2',
109109
'is_active' => true
110110
]
111111
);
@@ -114,7 +114,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey()
114114
$this->storeManager->setCurrentStore($secondStore);
115115

116116
$category2 = $this->categoryRepository->get($category2->getId());
117-
$category2->setUrlKey(null);
117+
$category2->setUrlKey('category-2');
118118
$this->categoryRepository->save($category2);
119119

120120
$this->storeManager->setCurrentStore(StoreModel::DEFAULT_STORE_ID);

0 commit comments

Comments
 (0)