【问题标题】:How to get the custom values and image in Magento in Topmenu?如何在 Topmenu 中获取 Magento 中的自定义值和图像?
【发布时间】:2013-03-14 17:24:01
【问题描述】:

我正在使用 ma​​gento 1.7.0.2。我已经在数据库中添加了自定义值。但是如何在 Topmanu 中检索自定义值和图像。我已经尝试在“my_attribute”的地方使用下面提到的代码来替换我的属性,但我没有得到结果。

模型:Mage_Catalog_Model_Observer

方法:_addCategoriesToMenu()

$categoryData = 数组(

'name' => $category->getName(),
'id' => $nodeId,
//'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
'is_active' => $this->_isActiveMenuCategory($category),
'my_attribute' => $category->getData('my_attribute') // Add our data in...

);

当我打印数组时,我会得到这个,

数组([name] => Matelas [id] => category-node-31 [is_active] => 1 [my_attribute] =>)

谁能指导我,提前谢谢...

【问题讨论】:

  • 你的意思是分类图片?你的意思是什么自定义值?
  • 我已经使用下面的代码获得了自定义类别值。但是同一个地方 ('my_attribute') ,替换图片属性就不行了。我需要在 Topmenu 中显示图像。

标签: magento zend-framework menu magento-1.7 categories


【解决方案1】:

我猜你的意思是你已经向 Category 实体添加了一个新的自定义属性?

因为您正在处理 Node_collection,所以不会加载完整的类别对象,请尝试加载完整的对象以获得您想要的:

$cat = Mage::getModel('catalog/category')->load($category->getId());

$categoryData = array(
    name' => $category->getName(),
    'id' => $nodeId,
    //'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
    'is_active' => $this->_isActiveMenuCategory($category),
    'my_attribute' => $cat->getData('my_attribute') // Add our data in...
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    相关资源
    最近更新 更多