I generated an sitemap.xml file through the Catalog > Google sitemap area.
What I experience is that the product url's in the .xml appears to be incorrect url-path'wise.
So a product url appears as:
http://www.domain.com/product1.html
While the correct on-site canonical url would be:
http://www.domain.com/category1/subcat/product1.html
In Configuration > Catalog > SEO, all is set to Yes/activated.
Any ideas on why this is happening and how it can be fixed?
Best Answer
This is not a bug, It's a feature.
take a look at how the products are retrieved for generating the xml sitemap.
Mage_Sitemap_Model_Resource_Catalog_Product::getCollection()
The code above represents the join condition with the url rewrites table.
So the url retrieved is the one that has the
category_id
set toNULL
.This translates into
www.somewebsite.com/product-url.html
.If you want to change this functionality, you can try to rewrite this piece of code to include a url rewrite where the
category_id
is notNULL
. but this may lead to strange results, because the products can be places in 0 to all categories.