2

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?

1 Answer 1

1

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()

    $urCondions = array(
        'e.entity_id=ur.product_id',
        'ur.category_id IS NULL',
        $this->_getWriteAdapter()->quoteInto('ur.store_id=?', $store->getId()),
        $this->_getWriteAdapter()->quoteInto('ur.is_system=?', 1),
    );

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 to NULL.
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 not NULL. but this may lead to strange results, because the products can be places in 0 to all categories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.