Skip to content

Commit 068cd98

Browse files
committed
MC-4244: Skip URL rewrites multiplication
1 parent 8b26e74 commit 068cd98

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac
330330
* @param TableMaintainer|null $tableMaintainer
331331
* @param PriceTableResolver|null $priceTableResolver
332332
* @param DimensionFactory|null $dimensionFactory
333-
* @param DbStorage|null $urlFinder
334333
*
335334
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
336335
*/
@@ -359,8 +358,7 @@ public function __construct(
359358
MetadataPool $metadataPool = null,
360359
TableMaintainer $tableMaintainer = null,
361360
PriceTableResolver $priceTableResolver = null,
362-
DimensionFactory $dimensionFactory = null,
363-
DbStorage $urlFinder = null
361+
DimensionFactory $dimensionFactory = null
364362
) {
365363
$this->moduleManager = $moduleManager;
366364
$this->_catalogProductFlatState = $catalogProductFlatState;
@@ -394,7 +392,19 @@ public function __construct(
394392
$this->priceTableResolver = $priceTableResolver ?: ObjectManager::getInstance()->get(PriceTableResolver::class);
395393
$this->dimensionFactory = $dimensionFactory
396394
?: ObjectManager::getInstance()->get(DimensionFactory::class);
397-
$this->urlFinder = $urlFinder ?: ObjectManager::getInstance()->get(DbStorage::class);
395+
}
396+
397+
/**
398+
* Retrieve urlFinder
399+
*
400+
* @return GalleryReadHandler
401+
*/
402+
private function getUrlFinder()
403+
{
404+
if ($this->urlFinder === null) {
405+
$this->urlFinder = ObjectManager::getInstance()->get(DbStorage::class);
406+
}
407+
return $this->urlFinder;
398408
}
399409

400410
/**
@@ -1437,7 +1447,7 @@ protected function _addUrlRewrite()
14371447
$filter['metadata']['category_id'] = $this->_urlRewriteCategory;
14381448
}
14391449

1440-
$rewrites = $this->urlFinder->findAllByData($filter);
1450+
$rewrites = $this->getUrlFinder()->findAllByData($filter);
14411451
foreach ($rewrites as $rewrite) {
14421452
if ($item = $this->getItemById($rewrite->getEntityId())) {
14431453
$item->setData('request_path', $rewrite->getRequestPath());

app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ protected function doFindOneByData(array $data)
113113
*/
114114
protected function doFindAllByData(array $data)
115115
{
116-
117116
$rewrites = parent::doFindAllByData($data);
118117

119118
$remainingProducts = [];

0 commit comments

Comments
 (0)