Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何调用自定义模块的管理控制器_Php_Magento_Plugins_Module_Controller - Fatal编程技术网

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

Php 如何调用自定义模块的管理控制器,php,magento,plugins,module,controller,Php,Magento,Plugins,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 fu

如何使用以下代码调用自定义模块的管理控制器。我试图在谷歌上搜索,但什么也找不到

下面是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
管理
myu类型转换器
abc
Mynamespace\u TypeChanger\u Block\u Adminhtml\u Catalog\u Product\u Grid
Mynamespace\u类型转换器\u助手

您可以在Grid.php中添加url标记,如下所示

 $this->getMassactionBlock()->addItem(
                'typechanger',
                array('label' => $this->__('Change Type'),
                      'url'  => $this->getUrl('*/*/massChangeType', array('_current'=>true)),
        //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')
                            )    
                 )    
               )
            );
控制器名称应该是什么样的

Mynamespace_TypeChanger_Adminhtml_Catalog_ProductController
\Mynamespace\TypeChanger\controllers\Adminhtml\Catalog\ProductController.php
anb路径应该是

Mynamespace_TypeChanger_Adminhtml_Catalog_ProductController
\Mynamespace\TypeChanger\controllers\Adminhtml\Catalog\ProductController.php
因为您必须定义函数
massChangeType
或自定义名称

并在
config.xml

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mynamespace_TypeChanger before="Mage_Adminhtml">Mynamespace_TypeChanger_Adminhtml</Mynamespace_TypeChanger>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

Mynamespace\u TypeChanger\u Adminhtml