Magento - 我在哪里可以编辑输出站点地图的文件?
我想更新在 Magento 1.5 中生成 google 站点地图的模板。
原因是,Magento 使用的是 URLKey(例如 /my-jacket.html),而不是带有类别的完整 URL(例如 /outerwear/jackets/my-jacket.html)。
我正在网站的另一个地方(.html 站点地图)执行此操作,效果很好。当循环遍历类别内的产品时......
// 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';
它很丑陋但有效。不管怎样,我想对生成的谷歌站点地图做同样的事情,但在多次搜索它的生成位置后,我找不到它。有人指出我正确的方向吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相当确定没有简单的模板可以编辑。 XML 生成发生在模型内部,具体来说:
Mage_Sitemap_Model_Sitemap::generateXml()
。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()
.