我正在尝试获取不同商店 View 的类别页面的页面 URL 键。基本上我在我的 Magento 安装中设置了 3 个商店。现在我想在我的类别页面中实现 hrefhang 标签。 但是当我在默认商店时,我无法访问其他商店 View 的类别 URL 键,反之亦然。
我有从中获取的类别对象,
$category = Mage::registry('current_category');
有什么想法吗?
最佳答案
似乎在与当前商店不同的商店下获取类别 URL 的最佳方法是 make use of Magento’s Mage_Core_Model_App_Emulation
.以下是如何执行此操作的示例:
/**
* @var $categoryId - The numeric category ID you want to get the URL of.
* @var $altStoreId - The numeric ID of the other store view to get the URL from.
*/
$env = Mage::getSingleton('core/app_emulation')->startEnvironmentEmulation($altStoreId);
$category = Mage::getModel('catalog/category')->load($categoryId);
$altUrl = $category->getUrl();
Mage::getSingleton('core/app_emulation')->stopEnvironmentEmulation($env);
关于php - Magento : How to get category page URL keys for different store views?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30616824/