Skip to content

Commit bbb2c10

Browse files
committed
MAGETWO-72861: Category edit performance issue - for 2.3
- Add strict types; - Add scalar type hinting;
1 parent dbd303f commit bbb2c10

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

app/code/Magento/Catalog/Model/Category/Product/PositionResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Model\Category\Product;
79

810
/**
@@ -37,7 +39,7 @@ protected function _construct()
3739
* @param int $categoryId
3840
* @return array
3941
*/
40-
public function getPositions(int $categoryId)
42+
public function getPositions(int $categoryId): array
4143
{
4244
$connection = $this->getConnection();
4345

app/code/Magento/Catalog/Test/Unit/Model/Category/Product/PositionResolverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Test\Unit\Model\Category\Product;
79

810
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder/ProductLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogRule\Model\Indexer\IndexBuilder;
79

810
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -42,7 +44,7 @@ public function __construct(
4244
* @param array $productIds
4345
* @return ProductInterface[]
4446
*/
45-
public function getProducts($productIds)
47+
public function getProducts(array $productIds): array
4648
{
4749
$this->searchCriteriaBuilder->addFilter('entity_id', $productIds, 'in');
4850
$searchCriteria = $this->searchCriteriaBuilder->create();

app/code/Magento/CatalogRule/Plugin/Indexer/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function afterSave(
3636
) {
3737
/** @var \Magento\Catalog\Model\Category $result */
3838
$productIds = $result->getAffectedProductIds();
39-
if ($productIds && !$this->productRuleProcessor->isIndexerScheduled()) {
39+
if (!empty($productIds) && !$this->productRuleProcessor->isIndexerScheduled()) {
4040
$this->productRuleProcessor->reindexList($productIds);
4141
}
4242
return $result;

app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilder/ProductLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\CatalogRule\Test\Unit\Model\Indexer\IndexBuilder;
89

app/code/Magento/CatalogUrlRewrite/Observer/CategoryProcessUrlRewriteSavingObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8585
$mapsGenerated = false;
8686
if ($category->dataHasChangedFor('url_key')
8787
|| $category->dataHasChangedFor('is_anchor')
88-
|| $category->getChangedProductIds()
88+
|| !empty($category->getChangedProductIds())
8989
) {
9090
if ($category->dataHasChangedFor('url_key')) {
9191
$categoryUrlRewriteResult = $this->categoryUrlRewriteGenerator->generate($category);

0 commit comments

Comments
 (0)