How to add menu in magento admin panel?

寵の児 提交于 2020-01-14 05:31:06

问题


I am looking for some advice or information on how to do the following. I want to add one more menu in magento admin panel. I am trying many ways but not working. How can i add extra one menu in admin panel. please advise...


回答1:


If this is your custom module what you need to do is in etc/config.xml add the following:

<adminhtml>
  <menu>
      <report>
        <children>
          <module name>
            <title>Title to show in the menu bar</title>
            <sort_order>0</sort_order>
            <action>Modules controller action</action>
          </module name>
        </children>
      </report>
    </menu>
 </adminhtml>

The example above will add a new item to the reports tab and trigger an action in the controller to do something. Hope this helps.




回答2:


You can add menu using custom module the below tutorial help me a lot please click here




回答3:


I am creating one module.

info - Company name folder

ExtendedMenu - Module Name

I am creating 2 new folders in modules folder.

etc & Block

etc folder I am creating config.xml file

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Info_ExtendedMenu>
            <version>0.1.0</version>
        </Info_ExtendedMenu>
    </modules>
    <global>
        <blocks>
            <configurable>
                <class>Info_Configurable_Block</class>
            </configurable>
            <adminhtml>
                <rewrite>
                    <page_menu>Info_ExtendedMenu_Block_Adminhtml_Menu</page_menu>
                </rewrite>
            </adminhtml>
        </blocks>
        <blocks>
            <configurable>
                <class>Inchoo_Configurable_Block</class>
            </configurable>
        </blocks>
    </global>
</config>

Block -- Adminhtml - Menu.php

<?php
class Info_ExtendedMenu_Block_Adminhtml_Menu extends Mage_Adminhtml_Block_Page_Menu
{
    public function getMenuArray()
    {
        //Load standard menu
        $parentArr = parent::getMenuArray();

        //Prepare "View Sites" menu
        $parentArr['view_sites'] = array(
            'label' => 'Web2Print',
            'active'=>false ,
            'sort_order'=>0,
            'click' => 'return false;',
            'url'=>'#',
            'level'=>0,
            'last'=> true,
            'children' => array()
        );

        $app = Mage::app();

        $j = 0;

        $allWebsites = $app->getWebsites();
        $totalWebsiteCount = count($allWebsites) - 1;

        foreach ($allWebsites as $_eachWebsiteId => $websiteVal){
            $_storeName = $app->getWebsite($_eachWebsiteId)->getName();
            $baseUrl = $app->getStore($_eachStoreId)->getUrl();
            $_websiteUrl = array(
                            'label' => 'View Admin',
                            'active' => false ,
                            'click' => "var extraurl='w2p/admin/index.php';alert(this.href+extraurl); window.open(this.href+extraurl, 'Website - '+ this.href); return false;",
                            'sort_order' => $i++ * 10,
                            'level' => 2,
                            'url' => $baseUrl
                            );

            if(count($parentArr['view_sites']['children']) == $totalWebsiteCount){
                $_websiteUrl['last'] = true;
            } else {
                $_websiteUrl['last'] = false;
            }

            $parentArr['view_sites']['children'][$j - 1] = $_websiteUrl;

            $allStores = $app->getWebsite($app->getWebsite($_eachWebsiteId)->getId())->getStores();
            $totalCount = count($allStores);
            $i = 0;
            foreach ($allStores as $_eachStoreId => $val){
                $_websiteId = $app->getStore($_eachStoreId)->getWebsiteId();
                if($_websiteId == $j){
                    $_storeName = 'View Admin';
                    $baseUrl = $app->getStore($_eachStoreId)->getUrl();
                    $_websiteUrl = array(
                            'label' => $_storeName,
                            'active' => false ,
                            'click' => "var extraurl='w2p/admin/index.php';alert(this.href+extraurl); window.open(this.href+extraurl, 'Website - '+ this.href); return false;",
                            'sort_order' => $i++ * 10,
                            'level' => 2,
                            'url' => $baseUrl
                            );

                    if(count($parentArr['view_sites']['children'][$j - 1]['children']) + 1 == $totalCount or $totalCount == 0)
                        $_websiteUrl['last'] = true;
                        else
                        $_websiteUrl['last'] = false;

                    $parentArr['view_sites']['children'][$j - 1]['children'][$i] = $_websiteUrl;
                }
            }
        }
        return $parentArr;
    }
}

Also you need to go to magento base folder path app-etc-modules-youemodule name(Inchoo_ExtendedMenu.xml)

<?xml version="1.0"?>
<config>
    <modules>
        <Inchoo_ExtendedMenu>
            <active>true</active>
            <codePool>local</codePool>
        </Inchoo_ExtendedMenu>
    </modules>
</config>

Menu creation over. cheers.




回答4:


What menu? Are you talking about an extension?

In order to do that you have: System > Magento connect > Magento connect manager

EDIT:

Theres an extension to manage this, take a look: Custom Menu Magento



来源:https://stackoverflow.com/questions/16186418/how-to-add-menu-in-magento-admin-panel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!