Skip to content

Commit f70f1b2

Browse files
committed
MC-4244: Skip URL rewrites multiplication
1 parent 6ceb3b8 commit f70f1b2

File tree

3 files changed

+12
-31
lines changed

3 files changed

+12
-31
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\ResourceConnection;
1515
use Magento\CatalogUrlRewrite\Model\ResourceModel\Category\Product;
1616
use Magento\Store\Model\ScopeInterface;
17+
use Magento\Tests\NamingConvention\true\string;
1718
use Magento\UrlRewrite\Model\OptionProvider;
1819
use Magento\UrlRewrite\Model\Storage\DbStorage as BaseDbStorage;
1920
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
@@ -140,7 +141,7 @@ protected function doFindAllByData(array $data)
140141
* @param int $storeId
141142
* @return string
142143
*/
143-
private function getCategoryUrlSuffix($storeId = null)
144+
private function getCategoryUrlSuffix($storeId = null): string
144145
{
145146
return $this->config->getValue(
146147
CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX,
@@ -155,7 +156,7 @@ private function getCategoryUrlSuffix($storeId = null)
155156
* @param array $data
156157
* @return array|null
157158
*/
158-
private function findProductRewriteByRequestPath(array $data)
159+
private function findProductRewriteByRequestPath(array $data): ?array
159160
{
160161
$requestPath = $data[UrlRewrite::REQUEST_PATH] ?? null;
161162

@@ -210,7 +211,7 @@ private function findProductRewriteByRequestPath(array $data)
210211
* @param array $data
211212
* @return array
212213
*/
213-
private function findProductRewritesByFilter(array $data)
214+
private function findProductRewritesByFilter(array $data): array
214215
{
215216
if (empty($data[UrlRewrite::ENTITY_TYPE])) {
216217
return [];
@@ -248,9 +249,9 @@ private function findProductRewritesByFilter(array $data)
248249
* Return base name for path
249250
*
250251
* @param string|null $string
251-
* @return mixed
252+
* @return string
252253
*/
253-
private function getBaseName($string)
254+
private function getBaseName($string): string
254255
{
255256
return preg_replace('|.*?([^/]+)$|', '\1', $string, 1);
256257
}

app/code/Magento/CatalogUrlRewrite/Plugin/DynamicCategoryRewrites.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
namespace Magento\CatalogUrlRewrite\Plugin;
99

1010
use Magento\Framework\App\Config\ScopeConfigInterface;
11-
use Magento\Store\Api\StoreResolverInterface;
12-
use Magento\Store\Model\ScopeInterface;
1311
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
1412
use Magento\CatalogUrlRewrite\Model\Storage\DynamicStorage;
1513
use Magento\CatalogUrlRewrite\Model\Storage\DbStorage;
@@ -29,32 +27,24 @@ class DynamicCategoryRewrites
2927
*/
3028
private $dynamicStorage;
3129

32-
/**
33-
* @var StoreResolverInterface
34-
*/
35-
private $storeResolver;
36-
3730
/**
3831
* @param ScopeConfigInterface|null $config
39-
* @param StoreResolverInterface $storeResolver
4032
* @param DynamicStorage $dynamicStorage
4133
*/
4234
public function __construct(
4335
ScopeConfigInterface $config,
44-
StoreResolverInterface $storeResolver,
4536
DynamicStorage $dynamicStorage
4637
) {
4738
$this->config = $config;
4839
$this->dynamicStorage = $dynamicStorage;
49-
$this->storeResolver = $storeResolver;
5040
}
5141

5242
/**
5343
* Check config value of generate_category_product_rewrites
5444
*
5545
* @return bool
5646
*/
57-
private function isCategoryRewritesEnabled()
47+
private function isCategoryRewritesEnabled(): bool
5848
{
5949
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
6050
}

app/code/Magento/UrlRewrite/Model/CompositeUrlFinder.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99

1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Framework\ObjectManagerInterface;
12-
use Magento\Store\Api\StoreResolverInterface;
13-
use Magento\Store\Model\ScopeInterface;
14-
use \Magento\UrlRewrite\Model\MergeDataProviderFactory;
15-
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
12+
use Magento\UrlRewrite\Model\MergeDataProviderFactory;
1613

1714
/**
1815
* Class CompositeUrlFinder
@@ -33,43 +30,36 @@ class CompositeUrlFinder implements UrlFinderInterface
3330
* @var MergeDataProviderFactory
3431
*/
3532
private $mergeDataProviderFactory;
33+
3634
/**
3735
* @var ScopeConfigInterface
3836
*/
3937
private $config;
4038

41-
/**
42-
* @var StoreResolverInterface
43-
*/
44-
private $storeResolver;
45-
4639
/**
4740
* @param array $children
4841
* @param ObjectManagerInterface $objectManager
4942
* @param MergeDataProviderFactory $mergeDataProviderFactory
5043
* @param ScopeConfigInterface $config
51-
* @param StoreResolverInterface $storeResolver
5244
*/
5345
public function __construct(
5446
array $children,
5547
ObjectManagerInterface $objectManager,
5648
MergeDataProviderFactory $mergeDataProviderFactory,
57-
ScopeConfigInterface $config,
58-
StoreResolverInterface $storeResolver
49+
ScopeConfigInterface $config
5950
) {
6051
$this->children = $children;
6152
$this->objectManager = $objectManager;
6253
$this->mergeDataProviderFactory = $mergeDataProviderFactory;
6354
$this->config = $config;
64-
$this->storeResolver = $storeResolver;
6555
}
6656

6757
/**
6858
* Check config value of generate_category_product_rewrites
6959
*
7060
* @return bool
7161
*/
72-
private function isCategoryRewritesEnabled()
62+
private function isCategoryRewritesEnabled(): bool
7363
{
7464
return (bool)$this->config->getValue('catalog/seo/generate_category_product_rewrites');
7565
}
@@ -113,7 +103,7 @@ public function findOneByData(array $data)
113103
*
114104
* @return array
115105
*/
116-
private function getChildren()
106+
private function getChildren(): array
117107
{
118108
uasort($this->children, function ($first, $second) {
119109
return (int)$first['sortOrder'] <=> (int)$second['sortOrder'];

0 commit comments

Comments
 (0)