如何调用自定义模块的管理控制器

时间:2014-08-05 14:47:05

标签: php magento module controller

如何使用以下代码调用自定义模块的管理控制器。我试图在谷歌搜索但无法找到任何东西

以下是Mynamespace / TypeChanger / Block / Adminhtml / Catalog / Product / Grid.php的代码

   class Mynamespace_TypeChanger_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
    {
         protected function _prepareMassaction()
        {
            parent::_prepareMassaction();

            // Append new mass action option
          $this->getMassactionBlock()->addItem(
                    'typechanger',
                    array('label' => $this->__('Change Type'),
                          'url'   => $this->getUrl('abc'),
         //this should be the url where there will be mass operation

                'additional' => array(
                            'visibility' => array(
                                 'name' => 'type',
                                 'type' => 'select',
                                 'class' => 'required-entry',
                                 'label' => Mage::helper('catalog')->__('Type'),
                                 'values' => array('simple' => 'simple','grouped' => 'grouped' , 'configurable' => 'configurable' ,'virtual'=> 'virtual', 'bundle'=> 'bundle', 'downloadable'=>'downloadable')
                             )

                )

               )
                );
        }
    }

这是config.xml的代码

 <?xml version="1.0"?>
    <config>
        <modules>
            <Mynamespace_TypeChanger>
                <version>1.0</version>
            </Mynamespace_TypeChanger>
        </modules>

        <admin>
            <routers>
                <typechanger>
                    <use>admin</use>
                    <args>
                        <module>Mynamespace_TypeChanger</module>
                        <frontName>abc</frontName>
                    </args>
                </typechanger>
            </routers>

        </admin>

       <global>
            <blocks>
                <adminhtml>
                    <rewrite>
                        <catalog_product_grid>Mynamespace_TypeChanger_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
                    </rewrite>
                </adminhtml>
            </blocks>

        <helpers>
                <typechanger>
                    <class>Mynamespace_TypeChanger_Helper</class>
                </typechanger>
        </helpers>

        </global>

    </config>

1 个答案:

答案 0 :(得分:0)

您的模块文件夹名称错误。Each folder name should be start with Capital lette r不小写。然后根据to Folder paths class Name应该是 从

mynamespace_mymodule_Block_Adminhtml_Catalog_Product_Grid

Mynamespace_Mymodule_Block_Adminhtml_Catalog_Product_Grid

另外 从 <module>mynamespace_mymodule</module&GT; 到

<module>Mynamespace_Mymodule</module>

文件夹路径如=

Mynamespace/Mymodule/Block/Adminhtml/.../Grid.php

更多关于模块的研究检查http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/