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
538538 continue ;
539539 }
540540 $ 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+ }
541558 $ urls [] = [
542559 $ this ->urlRewriteFactory ->create ()
543560 ->setEntityType (ProductUrlRewriteGenerator::ENTITY_TYPE )
544561 ->setEntityId ($ productId )
545562 ->setRequestPath ($ requestPath )
546- ->setTargetPath ($ this -> productUrlPathGenerator -> getCanonicalUrlPath ( $ product , $ category ) )
563+ ->setTargetPath ($ targetPath )
547564 ->setStoreId ($ storeId )
548565 ->setMetadata (['category_id ' => $ category ->getId ()])
549566 ];
You can’t perform that action at this time.
0 commit comments