20

Pretty much everything is in the title of my question.

What is the difference between the columns url_path and url_key in the flat products tables - like catalog_product_flat_(store_id) - of Magento ?

Thanks !

Laila
  • 1,421
  • 3
  • 13
  • 27

1 Answers1

25
  • url_key is the field you fill in the admin as is. (If there is nothing specified it create one by using the name of the product by lowercasing it and replace blank in it with hyphen).

  • url_path will be a concatenation of url_key and the Product URL Suffix defined under System > configuration > Catalog > Search Engine Optimization. It will also ensure that you do not have duplicate url_path by suffixing your url_key with an hyphen and the entity_id of the product if the same url_key already exists.

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
  • Thanks for your answer ! And which one of these attributes appears on front-end ? (in the tag for example to a product page). I guess it's url_path ? – Laila Mar 04 '15 at 19:50
  • 1
    Pleasure. At least url_path, yes, but that can also be a concatenation of the path of the categories (category, sub-category, sub-sub-category, ...) where the product lies (and where the user browse it, because one product can be in two categories), and this url_path. e.g. : if url_path is **product.html**, the url can display **example.com/categ/sub-categ/product.html** or **example.com/categ/other-sub-categ-where-the-product-also-is/product.html** or **example.com/product.html** because the user come from the search and search is outside the categories scope... – β.εηοιτ.βε Mar 05 '15 at 09:13
  • To test, I have edited the columns `url_key` and `url_path` (in the catalog_product_flat table) with dummy values for a product, flushed my cache and it seems like neither `url_path` or `url_key` is used for the links. I have edited the column matching with the attribute_code '97' in the table catalog_product_entity_varchar and reindexed catalog_url. It looks like the values displayed on the catalog page / SRP are the one made in the rewrite tables... – Laila Mar 05 '15 at 17:55
  • 1
    Well, there is really too much to answer on that subject that the limited format of the comment would allow me to. But I guess you have a bigger frame question you rightly narrowed to fit Stack Overflow guide lines, which is great but you may consider editing your question, or post a new one to explain exactly what is your purpose/problem. Basically, yes, the info on flat table are only there to have a copy of EAV table and faster sql requests, and the whole rewrite / SEO friendly url are managed by another module Mage_Core_Url, and his corresponding db table. – β.εηοιτ.βε Mar 06 '15 at 09:22
  • URLs for products are created using the core_url_rewrite table. I believe the attribute url_path is used to generate the rows in core_url_rewrite, but not 100% sure. – Wouter Oct 11 '18 at 08:25