I would like to update the template that generates the google sitemap in Magento 1.5.
Reason being, Magento is using the URLKey (e.g. /my-jacket.html) and not the full URL with category (e.g. /outerwear/jackets/my-jacket.html).
I’m doing this in another place on the site (an .html sitemap) and it works great. When looping through products inside a category…
// get the categories for this product
$_categories = Mage::getModel('catalog/product')->load($product_id)->getCategoryIds();
$_category = Mage::getModel('catalog/category')->load($_categories[0]);
// build the URL path
$url = Mage::getUrl($_category->getUrlPath()).basename($_product->getUrlKey());
// only problem is this will be /category/category2.html/my-jacket.html
// so strip the .html and put it on the end
$url = str_replace(".html","" ,$url) . '.html';
It’s ugly but works. Anyway, I want to do the same to the google sitemap that gets generated, but after much searching for where it is generated, I can’t find it. Anyone point me in the right direction?
I’m fairly certain that there’s no simple template to edit. The XML generating happens inside of a model, specifically:
Mage_Sitemap_Model_Sitemap::generateXml().