作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我们想要获取请求路径来构建动态 URL
public function countryStoresAlternateLinks(){
$stores = Mage::app()->getStores(false);
$countryAlternateLinks = '';
foreach($stores as $store) {
$countryAlternateLinks[] = '<link rel="alternate" hreflang="' . substr(Mage::getStoreConfig('general/locale/code', $store->getId()), 0, 2) . (Mage::getStoreConfig('general/country/default', $store->getId()) != '' ? "-" . Mage::getStoreConfig('general/country/default', $store->getId()) : '') . '" href="' . $store->getCurrentUrl(false) .'" />' . "\n";
}
return $countryAlternateLinks; }
给出以下输出:
<link rel="alternate" hreflang="en-GB" href="http://our_domain.com/magento/thee/losse- bladthee/groene?SID=4d6ec9b2ada547a58c7b57dfb35b8d95&___store=english" />
<link rel="alternate" hreflang="nl-NL" href="http://www.our_domain.nl/magento/thee/losse-bladthee/groene?___store=dutch" />
<link rel="alternate" hreflang="nl-BE" href="http://our_domain.com/magento/thee/losse-bladthee/groene?SID=4d6ec9b2ada547a58c7b57dfb35b8d95&___store=nl_be" />
<link rel="alternate" hreflang="fr-BE" href="http://our_domain.com/magento/thee/losse-bladthee/groene?SID=4d6ec9b2ada547a58c7b57dfb35b8d95&___store=fr_be" />
该函数将打印每个商店的基本 URL,但类别路径不会因每个商店 View 而改变,它会以相同的语言提醒。
*问题是 – 我们如何指定“href”以获取每个商店 View /语言的类别路径?*
这就是我们目前得到的“href="' . $store->getCurrentUrl(false) .'”有谁知道我们如何才能做到这一点?
感谢您的回复,但不完全是我们正在寻找的。也许我在第一条消息中没有解释清楚,抱歉。
最后我们要调用的是其他店铺的rewrite URL,例如:
代替:
www.domain.com/cat1/sub2/info-english.html
我们想调用:
www.domain.com/cat-fr/sub-fr/info-french.html
这在原来的英文商店里,所以我们有很好的干净链接?有没有办法在 Magento 中实现这一目标?
谢谢
最佳答案
`Mage::getModel('catalog/category')
->setStoreId(each store id)
->load(YOUR_CATEGORY_ID);`
这将根据商店 ID 加载每个类别。获取网址
希望你得到了需要的东西
:)
关于magento - 如何在多商店 Magento 设置中获取请求路径以在 hreflang 中使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16220614/
我是一名优秀的程序员,十分优秀!