Magento2: "Use Categories Path for Product URLs" not working for intermediate categories

Created on 13 Dec 2017  路  13Comments  路  Source: magento/magento2

When using category path for product url, there is no generated url key for intermediate categories. In the url key table you can find one url rewrite for 1st level category and one for last level category.

This seems to work only on the last level category.


Preconditions


  1. Magento 2.1.10 with sample data
  2. PHP7

Steps to reproduce

  1. Enable product url by categories in Stores > Configuration > Catalog > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
  2. On the frontend, click on Women > Tops in the main menu

Expected result

  1. For the product "Selene Yoga Hoodle", the url_key is "women/tops-women/selene-yoga-hoodle.html"

Actual result

  1. The url_key is "catalog/product/view/id/1113/s/selene-yoga-hoodie/category/21/"

Clear Description Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x

All 13 comments

Is this issue relevant for 2.2.x by the way?

Same issue on magento 2.2.2-dev fresh install.

@AymericJoubert, thank you for your report.
We've created internal ticket(s) MAGETWO-85642 to track progress on the issue.

mageconf

@orlangur thank you for joining. Please accept team invitation here and self-assign the issue.

Hey guys any update on this issue? or some way to get around?

Up :)
This is really annoying in prod environments...
Any update ?

Best, is there a solution we have the same issue in prod our prod environment....
This magento 2 is out now for too long to have issues like this. Even extension developers are walking behind the versions. Almost all extensions there are are outdated and we run from one to the second issue and so on. It is a shame magento is still fully in beta even with version 2.2.2 Hoping for a quick solution. Solutions like this take ages even if there are 20 posts from the same issue. We can not wait for the next version change with this. Content is depending on these clean URL's. Again a quick solution would be nice.

Why anyone need to switch "Use Categories Path for Product URLs" on prod?

some way to get around?

@lasg125 the problem here is that URL rewrites cannot be recreated from nowhere. Unlike the switch of suffix (like .html), changing this option requires removal/creation of additional URL rewrites.

As a workaround you can re-save all products programmatically. As a permanent solution most likely some kind of similar asynchronous operation is needed, it is not possible immediately after you change setting via Admin UI in case of a big catalog.

@lasg125

We tried a lot of solutions (after a back-up of the database) but nothing seems to work on magento 2.2.2

Our last solution was this one : https://github.com/olegkoval/magento2-regenerate_url_rewrites

For now it seems to work and we hope it will stay like this.

Hope it helps, many thanks to Oleg Koval (which provides this for free.)

For me I couldn't replicate the issue above on 2.2.6, but I landed here by replicating (and then treating) the symptoms described.

The setting "Stores > Configuration > Catalog > Catalog > Search Engine Optimization > Use Categories Path for Product URLs" only generates aliases for Categories of which the product is directly assigned to, and will not generate aliases for products that are only members of categories via the Category setting "Is Anchor".

For example, the category tree below:

-> Appliances
--> Kitchen
---> Toasters

You might set "Appliances" and "Kitchen" to both be Anchor Categories, and only assign the product to the Toasters category, and let "Is Anchor" automatically define your Toasters are also within both "Kitchen" and "Appliances".

For me this resulted in my Product URLs not getting Category Paths for the categories "Appliances" and "Kitchen", but getting Category Paths for the Product URLs auto-aliased for the "Toasters" path.

Hope someone finds this useful.

Hi @engcom-Echo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


Hello All

I am not able to reproduce this issue on the 2.4-develop branch by provided steps.

Testing scenario:

Preconditions
Magento 2.4 with sample data

Steps to reproduce:

  1. Enable product url by categories in Stores > Configuration > Catalog > Catalog > Search Engine Optimization > Use Categories Path for Product URLs
  2. On the frontend, click on Women > Tops in the main menu

Result
For the product "Selene Yoga Hoodle", the url_key is "women/tops-women/selene-yoga-hoodle.html"
Screenshot_51
Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.

Was this page helpful?
0 / 5 - 0 ratings