Skip to content

This extension adds console commands to be able to regenerate; a product rewrite URL based on its url path; a category rewrite URL based on its url path; a category URL path based on its URL key and its parent categories.

License

Notifications You must be signed in to change notification settings

Tjitse-E/magento2-regenurl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2 - Fix broken multistore category urls

This fork of peterjaap/magento2-regenurl adds a command to fix broken category urls on Magento 2.2.x. You can find more info about the issue here: #16202

We've used this solution once, on one of our Magento stores running Magento 2.2.4, with over 30 store views using four languages. Never try this on production without testing!

The problem

When you're running a Magento 2.2 store with multiple store views, let's say three stores in different languages (Dutch, French and German), sometimes the category urls will start to deform like this:.

The solution

We've tested this solution on one of our Magento stores running Magento 2.2.4, with over 30 store views using four languages

  1. Identify the problem by running the following SQL query:
SELECT * FROM `url_rewrite` WHERE `entity_type` LIKE 'category' AND `entity_id` IN (category, ids, here) AND `store_id` = 8 ORDER BY `url_rewrite_id`

In our case this resulted in multiple bad 301 redirects, plus the wrong category urls. 2. Delete the url_rewrites:

DELETE FROM `url_rewrite` WHERE `entity_type` LIKE 'category' AND `entity_id` IN (category, ids, here) AND `store_id` = 8 ORDER BY `url_rewrite_id`
  1. Run the command php bin/magento regenerate:product:path -s storeId cids 1 2 3 5
  2. Run the command php bin/magento regenerate:product:url -s storeId cids 1 2 3 5

Automating the solution

I've created a command that will do this for you automatically:

php bin/magento regenerate:category:tree --category categoryId --store storeId

In our case it didn't work to regenerate one of the deepest level subcategories. We had to use one of the top level categories to make this work. The command will automatically fix the parent and the child categories.

Output:

Output screenshot

Before:

Before screenshot

After:

After screenshot

Regeneration product urls

php bin/magento regenerate:product:url -s 1 --only-visible=1

The only-visible flag is optional, it will regenerate the product urls only for products that are visible (n.b. no 'Not visible individually'). See #3.

Install

Using Composer;

composer config repositories.regenurl vcs [email protected]:Tjitse-E/magento2-regenurl.git
composer require iazel/module-regen-product-url
php bin/magento setup:upgrade

Or download and copy the Iazel directory into app/code/ and run php bin/magento setup:upgrade.

About

This extension adds console commands to be able to regenerate; a product rewrite URL based on its url path; a category rewrite URL based on its url path; a category URL path based on its URL key and its parent categories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%