Php 如何在Magento中获取原始(所有商店视图)的当前类别名称?

Php 如何在Magento中获取原始(所有商店视图)的当前类别名称?,php,magento,Php,Magento,我如何在Magento中获得“原始”类别名称,我已经为当前商店视图翻译了类别名称。我想获得所有商店视图中输入的类别名称,因为我想将原始(英文)名称发送给GA进行跟踪-当我在类别页面上时,我需要这个 我可以通过以下方式获取本地化类别名称: <?php $currentCategory = Mage::registry('current_category'); $name = $currentCategory->getName(); ?> 但是,在没有对数据库进行额外调用的

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

我可以通过以下方式获取本地化类别名称:

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


但是,在没有对数据库进行额外调用的情况下,无法找到获取未翻译名称的方法。

如上所述,这将需要额外的数据库请求。以下方面应起作用:

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

$name = $defaultStoreCategory->getName();
请尝试使用此代码

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

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

希望这有帮助。

这将需要对数据库进行额外的调用。因此,您可能已经找到了解决方案。我仍在搜索解决方案,即使有其他DB调用。这在Magento 1.7中失败:“致命错误:对非对象调用成员函数setStoreId()”我的错,应该是
getResource()
,而不是
getResourceModel()
。我将更新答案…您的代码仍然为我提供本地化的类别名称,但如果我省略对“getResource()”的调用,而直接在模型上调用“setStoreId()”(如下面的@magento代码所建议的),那么它就可以工作了