【发布时间】:2017-02-21 09:48:11
【问题描述】:
我正在处理magento 的项目,我试图在主导航中列出一个菜单项。其中每个模型有一个observer。我要做的是使用现有的观察者添加另一个菜单项。为此我创建了一个函数:
class Color_Observer{
// Existing function for "colors" menu item.
public function ListMenuItems(){
//code here
}
// New function for "composite colors" menu item
public function MyListMenuItems(){
//
}
}
我在config.xml中添加了以下代码
<frontend>
<events>
<page_block_html_topmenu_gethtml_before>
<observers>
<my_color>
<class>my_color/observer</class>
<method>ListMenuItems</method>
</my_color>
<my_color_val>
<class>my_color/observer</class>
<method>MyListMenuItems</method>
</my_color_val>
</observers>
</page_block_html_topmenu_gethtml_before>
</events>
</frontend>
此代码成功为composite colors 创建菜单,但它替换了现有的color 菜单。
谁能帮我看看这是怎么回事?我是magento 的新手。
【问题讨论】:
-
试试链接我希望你的问题可以解决。 inchoo.net/ecommerce/adding-links-to-the-top-menu-in-magento