olegkoval / magento2-regenerate_url_rewrites

Magento 2 extension which add feature of regenerating a url rewrites of products/categories
Academic Free License v3.0
420 stars 117 forks source link

Wrong product URL rewrites in Multistore setting #135

Open mtjweb opened 3 years ago

mtjweb commented 3 years ago

Describe the bug The generated URL's are generated from the default product name instead of the name in the scope.

Expected behavior Correct URL generated from the product name in the scope.

To Reproduce Use the command "php bin/magento ok:urlrewrites:regenerate" to generate new URL's. Check the products in the frontend, they are useing the default URL rewrite Check the URL-key when editing a product in, there you see the correct URL rewrite Check the url_rewrite table, the URL-keys are not in the table. Just the default URL rewrites.

Magento version 2.3.5-p1 Module version 1.5.6

mvenghaus commented 3 years ago

I had the same problem.

Add setStoreId to categoryCollection

Model/RegenerateCategoryRewrites.php:253 $categoriesCollection->addAttributeToSelect('name') ->setStoreId($storeId)

mvenghaus commented 3 years ago

I solved it by adding 2 lines. And before generating, I also had to set the following setting. I don't use the cli command so it was no problem to set the setting.

$this->regenerateCategoryRewrites->regenerateOptions['noRegenUrlKey'] = true;

Here's my patch: https://gist.github.com/mvenghaus/1aba55b6fb6965fadd42c594414c9f88