Coder Social home page Coder Social logo

Comments (14)

peterjaap avatar peterjaap commented on August 30, 2024 1

@amenk yes, see the faq

from magento2-regenerate-catalog-urls.

hostep avatar hostep commented on August 30, 2024 1

@amenk: Magento always writes the url_path for categories to the database, but never for products.

The url_path for a category consists of all the parent categories url_key's + its own url_key, all concatenated with a /.
The url_path for products was a left over from Magento 1 that for some reason didn't get removed in Magento 2 and when it's filled up will cause issues when you try to update the url_key of a product. So it's best to delete all of them.

Hope this makes it a bit more clear.

@peterjaap: maybe you should update the title What's the difference between url_key and url_path? to What's the difference between url_key and url_path for products? on the FAQ section of the README file? I believe it causes a bit confusion because @amenk seems to think it applies to category entities as well.
Also the section underneath Why are my category rewrites for a non-default storeview in the default storeview's language? is very incorrect in my opinion, you'd probably best delete it, don't you think?

from magento2-regenerate-catalog-urls.

peterjaap avatar peterjaap commented on August 30, 2024 1

The fact that that command is there doesn't say anything because the bin/magento regenerate:product:path used to be there as well ;)

I updated the readme accordingly :) ed2ed37

from magento2-regenerate-catalog-urls.

peterjaap avatar peterjaap commented on August 30, 2024

Unless you're running a very old Magento version (<=2.1), you don't need the path commands. See https://github.com/elgentos/regenerate-catalog-urls#whats-the-difference-between-url_key-and-url_path

Otherwise, first keys, then paths, because;

The url_path is generated by taking the url_key and adding the suffix

But make sure you have removed the paths if they're there, because Magento still uses them when they're present.

from magento2-regenerate-catalog-urls.

amenk avatar amenk commented on August 30, 2024

We are at 2.4.3 but I believe we have a lot of trash in the database from old version :-(

from magento2-regenerate-catalog-urls.

amenk avatar amenk commented on August 30, 2024

Ah, we can remove the paths? like from the EAV table?

from magento2-regenerate-catalog-urls.

peterjaap avatar peterjaap commented on August 30, 2024

Then I'd suggest cleaning up the database first. Garbage in is garbage out.

from magento2-regenerate-catalog-urls.

amenk avatar amenk commented on August 30, 2024

@peterjaap can you confirm, also the category's url_paths should be deleted?
Had this discussion with @hostep baldwin-agency/magento2-module-url-data-integrity-checker#14 (comment)

And on our staging where I deleted both, category's + product's url_path magento still seems to write them, but not all (after delete + rebuild I see 59 rows for

select * from catalog_category_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_path' AND entity_type_id = 3);

while before we had 5623 rows

We did not spot other url problems though...
We have 1415 categories and 5 stores.

from magento2-regenerate-catalog-urls.

peterjaap avatar peterjaap commented on August 30, 2024

@hostep so you're saying the url_path values are still used for categories? Apparently I decided otherwise when I wrote that README but I could indeed be very wrong. Do you have a code reference to see where/how it is used?

from magento2-regenerate-catalog-urls.

hostep avatar hostep commented on August 30, 2024

Yes exactly.

Code reference, hmm, this class sounds related probably: https://github.com/magento/magento2/blob/7996e89bc5420220eae5d8b755e6e0f839cbd94a/app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php

But the easiest way to tell is:

  • Setup a clean Magento
  • Using the backoffice: create one product and create one category
  • Inspect the catalog_product_entity_varchar and catalog_category_entity_varchar database tables
  • Notice that for the product, no entry was created for the url_path attribute, and for category an entry did get created

Also, don't forget that this very module has a command to regenerate url_path's for category's: bin/magento regenerate:category:path 😉

from magento2-regenerate-catalog-urls.

hostep avatar hostep commented on August 30, 2024

Okay great, thanks! 🙂

from magento2-regenerate-catalog-urls.

amenk avatar amenk commented on August 30, 2024

For the record concerning my original question:

This does not fix all URLs:

regenerate:category:url for all stores?
regenerate:category:path for all stores?
regenerate:product:url for all stores?

This does:

regenerate:category:path for all stores
regenerate:category:url for all stores
regenerate:product:url for all stores

from magento2-regenerate-catalog-urls.

hostep avatar hostep commented on August 30, 2024

Exactly, always generate paths before url rewrites (for categories)!

A month or so ago, I ran into a strange case when I needed to execute regenerate:category:path multiple times (up to 3 times) until everything was fixed, unfortunately I didn't have time to look into it back then ...

from magento2-regenerate-catalog-urls.

amenk avatar amenk commented on August 30, 2024

Oh wow, so I am not sure if the run-again fixed it in my case or the new order.

from magento2-regenerate-catalog-urls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.