php - Magento : How to get category page URL keys for different store views?

标签 php magento url

我正在尝试获取不同商店 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/

相关文章:

ruby - 检查一个字符串是否匹配一个正则表达式并剥离它的一部分以供使用

php - 尝试发布到 Laravel 上的 Redis 时,在 null 上调用成员函数publish()

php - 插入 8 个随机字符的唯一字符串

PHP - 高效显示内联 SVG 图像

magento - 目录价格规则与购物车规则

php - 按价格列出 Magento 中的产品,但最后的价格为零

PHP:使用多个选择下拉列表搜索mysql数据库?

magento - "Suspected Fraud"完成magento付款后的状态?

javascript - javascript 属性值可以通过手动 url 参数确定吗?

jquery - 如何在加载后删除部分 URL