3

如何在 Magento 中获取“原始”类别名称,我已经翻译了当前商店视图的类别名称。我想获取在所有商店视图中输入的类别名称,因为我想将原始(英文)名称发送到 GA 进行跟踪 - 当我在类别页面上时我需要这个。

我可以通过这种方式获得本地化的类别名称:

<?php 
$currentCategory = Mage::registry('current_category');
$name = $currentCategory->getName();
?>

但是如果不额外调用数据库,就无法找到一种方法来获取未翻译的名称。

4

2 回答 2

6

如上所述,这将需要额外的数据库请求。以下应该有效:

$defaultStoreCategory = Mage::getModel('catalog/category');
$defaultStoreCategory->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
$defaultStoreCategory->load($currentCategory->getId());

$name = $defaultStoreCategory->getName();
于 2013-01-28T10:14:32.283 回答
0

尝试使用此代码

 $storeId = Mage::app()->getStore()->getId();

 $product = Mage::getModel('catalog/category')
     ->setStoreId(Mage::app()->getStore()->getId())
     ->load(YOUR_CATEGORY_ID);

希望这可以帮助。

于 2013-01-28T11:01:53.590 回答