Magento - 我在哪里可以编辑输出站点地图的文件?

发布于 2025-01-04 04:17:05 字数 877 浏览 4 评论 0原文

我想更新在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

踏雪无痕 2025-01-11 04:17:05

我相当确定没有简单的模板可以编辑。 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().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文