Magento:如何获取不同商店中类别的URL?

时间:2014-11-23 11:40:09

标签: php magento

我有多种不同语言的商店浏览量,可通过domain.com/de,domain.com/fr等访问。

在这些商店内容中使用了相同的类别(例如,domain.com/de/mensfashion,domain.com/fr/mensfashion-大多数类别名称都没有翻译,但除此之外还有其他类别)。

现在,我想在那里生成一个具有rel-alternates的站点地图:

<loc>"http://domain.com/de/mensfashion"</loc>
<xhtml:link rel="alternate" hreflang="fr" href="http://domain.com/fr/mensfashion"/>
...

因此,对于某个类别,我需要能够遍历所有商店并获取该商店的URL。 通过

获取URL非常简单
Mage::app()->setCurrentStore($de_store_id);
Mage::getModel('catalog/category')->load($category_id)->getUrl();

但是无论我尝试更改为下一个$ fr_store_id,我都会为初始设置商店获取相同的URL ....

我尝试过(以下任意组合和顺序):

Mage::app()->setCurrentStore($fr_store_id);

Mage::getModel('catalog/category')->setStoreId($fr_store_id)->load($category_id);

$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($fr_store_id);

但这似乎没有做任何事情,我一直得到德国的结果......

我怀疑它与仅加载一次的模型有关,即一些缓存问题,我很清楚,在生成一个包含数百个链接的站点地图,每个链接有10个备选项,但它不是无论如何都要为每个链接转到数据库。 任何帮助将不胜感激!

PS如果唯一有效的方法是在SQL中也受到赞赏......但是很想知道代码中是否有一个简单的解决方案。

0 个答案:

没有答案
相关问题