usually we can see a product in magento with two URLs: htp://mysite.com/some-category/some-product.html or htp://mysite.com/some-product.html. I need to have all products visible by URL like htp://mysite.com/products/some-product.html. Most obvious way is to add a category ‘products’ and link all products to this category, but we have a few thousands of products in the catalog, so I’d like to do it in some programmatic way. Please give me a suggestion in which way I could do it? Now my idea is to overload class Mage_Core_Model_Url_Rewrite but I’m not sure if it is good idea.
I wonder that there is noone who can answer this question. I saw a lot of people complaining that our problem is their solution. By default magento should present the products like we want it with the category url key, but on my site this does not work.
The product name is without the category url even I selected it in the admin menu. Why is that so?
Hi all.
The problem is that 1 product can belong to several categories at once, that’s why if we can’t be sure that we are now in the category scope (I mean product listing), we can’t add category key to product url, because we don’t know exactly which one.
I also faced with this problem before, and I saw only one solution - get collection from all url rewrites which is related to current product and take the first one which has category_id != null. But it looks like hack because, in fact, we are getting “random” product url (if we have more than 1)
So, if you fit such kind of solution and you have a questions how to do that, please, write, I’ll try to help.