File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
app/code/Magento/CatalogUrlRewrite/Observer Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -538,12 +538,29 @@ private function categoriesUrlRewriteGenerate(array $products): array
538
538
continue ;
539
539
}
540
540
$ requestPath = $ this ->productUrlPathGenerator ->getUrlPathWithSuffix ($ product , $ storeId , $ category );
541
+ $ targetPath = $ this ->productUrlPathGenerator ->getCanonicalUrlPath ($ product , $ category );
542
+ if ((int ) $ storeId !== (int ) $ product ->getStoreId ()
543
+ && $ this ->isGlobalScope ($ product ->getStoreId ())) {
544
+ if ($ this ->cachedValues === null ) {
545
+ $ this ->cachedValues = $ this ->getScopeBasedUrlKeyValues ($ products );
546
+ }
547
+ if (!empty ($ this ->cachedValues ) && isset ($ this ->cachedValues [$ productId ][$ storeId ])) {
548
+ $ storeProduct = clone $ product ;
549
+ $ storeProduct ->setStoreId ($ storeId );
550
+ $ storeProduct ->setUrlKey ($ this ->cachedValues [$ productId ][$ storeId ]);
551
+ $ requestPath = $ this ->productUrlPathGenerator ->getUrlPathWithSuffix (
552
+ $ storeProduct ,
553
+ $ storeId ,
554
+ $ category
555
+ );
556
+ }
557
+ }
541
558
$ urls [] = [
542
559
$ this ->urlRewriteFactory ->create ()
543
560
->setEntityType (ProductUrlRewriteGenerator::ENTITY_TYPE )
544
561
->setEntityId ($ productId )
545
562
->setRequestPath ($ requestPath )
546
- ->setTargetPath ($ this -> productUrlPathGenerator -> getCanonicalUrlPath ( $ product , $ category ) )
563
+ ->setTargetPath ($ targetPath )
547
564
->setStoreId ($ storeId )
548
565
->setMetadata (['category_id ' => $ category ->getId ()])
549
566
];
You can’t perform that action at this time.
0 commit comments