experius / Magento2-Module-Experius-ReindexCatalogUrlRewrites

Adds a function to Magento 2 to fix or 'reindex' your catalog product urls rewrites with a console command line script
10 stars 2 forks source link

Too many redirects on home page #10

Open ctadlock opened 6 years ago

ctadlock commented 6 years ago

I updated to the latest version of the module (1.2.3), truncated the existing url-rewrite table and ran experius_reindexcatalogurlrewrites:categoryurls. My home page then had an issue with too may redirects. In order to get it to work; I had to remove two rows in the url_rewrite table.

Command output.. image

Had to remove these rows... image

Default Category is my root category. image

ctadlock commented 6 years ago

I think the issue is here (https://github.com/experius/Magento2-Module-Experius-ReindexCatalogUrlRewrites/blob/master/Console/Command/RegenerateCategoryUrlCommand.php#L251). If there are, or have been multiple root categories then there are categories under this root category. This code assumes that is not the case. I think a better fix would be to check if request_path != '/'.

ctadlock commented 6 years ago

For reference:

image

lewisvoncken commented 6 years ago

@ctadlock

you shouldn't truncate the table but only remove lines with the correct entity type id

ctadlock commented 6 years ago

@lewisvoncken yes, Im removing the two rows that are causing the issue. I truncated at the start to make sure I have a clean starting point for testing.

ctadlock commented 6 years ago

@lewisvoncken Also, this has nothing to do with an incorrect entity_type; they are all category. The issue is that its generating rewrites for categories with a request_path of / when it shouldn't. This is due to the incorrect logic of determining what categories should have rewrites.

ctadlock commented 5 years ago

@lewisvoncken Any plans to fix this issue?

ghost commented 5 years ago

@ctadlock Are you able to send us a pull request?

ctadlock commented 5 years ago

@dheesbeen I think you can handle fixing this since this is your code. Ive done my part in throughly identifying and diagnosing the issue.

peterjaap commented 4 years ago

@dheesbeen here's how I fixed it in our extension; https://github.com/elgentos/regenerate-catalog-urls/commit/6a31dc88c8eba00bca1bdea7f0310283d02d792c