Skip to content

Commit d96aca3

Browse files
committed
ACP2E-3900: Update product url_key via REST API does not generate a 301 URL Rewrite
- fixed static tests
1 parent adb70c1 commit d96aca3

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Magento\Framework\Api\ImageProcessorInterface;
2121
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
2222
use Magento\Framework\Api\SearchCriteriaInterface;
23-
use Magento\Framework\App\Config\ScopeConfigInterface;
2423
use Magento\Framework\DB\Adapter\ConnectionException;
2524
use Magento\Framework\DB\Adapter\DeadlockException;
2625
use Magento\Framework\DB\Adapter\LockWaitException;
@@ -215,7 +214,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
215214
* @param ReadExtensions $readExtensions
216215
* @param CategoryLinkManagementInterface $linkManagement
217216
* @param ScopeOverriddenValue|null $scopeOverriddenValue
218-
* @param ScopeConfigInterface|null $scopeConfig
219217
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
220218
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
221219
*/

app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@ class CurrentUrlRewritesRegenerator
3030
/**
3131
* @var Product
3232
* @deprecated 100.1.0
33+
* @see not used
3334
*/
3435
protected $product;
3536

3637
/**
3738
* @var ObjectRegistry
3839
* @deprecated 100.1.0
40+
* @see not used
3941
*/
4042
protected $productCategories;
4143

4244
/**
4345
* @var UrlFinderInterface
4446
* @deprecated 100.1.0
47+
* @see not used
4548
*/
4649
protected $urlFinder;
4750

@@ -87,6 +90,7 @@ class CurrentUrlRewritesRegenerator
8790
* @param UrlRewriteFinder|null $urlRewriteFinder
8891
* @param \Magento\UrlRewrite\Model\MergeDataProviderFactory|null $mergeDataProviderFactory
8992
* @param CategoryRepository|null $categoryRepository
93+
* @param ScopeConfigInterface|null $scopeConfig
9094
*/
9195
public function __construct(
9296
UrlFinderInterface $urlFinder,
@@ -176,10 +180,11 @@ public function generateAnchor(
176180
ProductUrlRewriteGenerator::ENTITY_TYPE,
177181
$rootCategoryId
178182
);
179-
180-
foreach ($productCategories->getList() as $productCategory) {
181-
$anchorCategoryIds = array_merge($productCategory->getAnchorsAbove(), $anchorCategoryIds);
182-
}
183+
$anchorCategoryIds = array_merge(
184+
...array_map(
185+
fn($productCategory) => $productCategory->getAnchorsAbove(), $productCategories->getList()
186+
)
187+
);
183188

184189
foreach ($currentUrlRewrites as $currentUrlRewrite) {
185190
$metadata = $currentUrlRewrite->getMetadata();
@@ -199,6 +204,8 @@ public function generateAnchor(
199204
}
200205

201206
/**
207+
* Generate URL rewrites for autogenerated URLs
208+
*
202209
* @param UrlRewrite $url
203210
* @param int $storeId
204211
* @param Category|null $category
@@ -227,6 +234,8 @@ protected function generateForAutogenerated($url, $storeId, $category, $product
227234
}
228235

229236
/**
237+
* Generate URL rewrites for custom URLs
238+
*
230239
* @param UrlRewrite $url
231240
* @param int $storeId
232241
* @param Category|null $category
@@ -255,6 +264,8 @@ protected function generateForCustom($url, $storeId, $category, $product = null)
255264
}
256265

257266
/**
267+
* Retrieve category from URL metadata
268+
*
258269
* @param UrlRewrite $url
259270
* @param ObjectRegistry|null $productCategories
260271
* @return Category|null|bool

0 commit comments

Comments
 (0)