如何使用以下代码调用自定义模块的admin控制器。我试着在谷歌上搜索,但无法找到任何
下面是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>
你好,你的模块文件夹名称是错误的。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
>
<module>Mynamespace_Mymodule</module>
文件夹路径like=
Mynamespace/Mymodule/Block/Adminhtml/.../Grid.php
更多的学习模块查看此http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/