更改管理网格集合的表名称

时间:2015-01-09 09:48:52

标签: magento collections alter-table

我为横幅创建了一个模块。它运作良好。在后端,我可以选择添加横幅图像并设置是否有效。最初,我创建了一个名为“横幅”的表,用于保存横幅记录。

现在我想更改表格名称,例如 chilly_banner 。我在DB中手动创建了“ chilly_banner ”表并插入了一些记录。

在admin banner网格中,我想显示此表中的集合。我什么都不知道,怎么做。但我在 _prepareCollection()方法

中尝试过这样的方法
$collection = Mage::getModel('banner/chilly_banner')->getCollection(); 

在模型文件中 _init()方法将横幅更改为 chilly_banner ,如上所述。

但是我收到了像

这样的错误
 Fatal error: Call to a member function getCollection() on a non-object
 in ../app/code/local/Chilly/Banner/Block/Adminhtml/Banner/Grid.php on
 line 18

知道如何更改网格集中的表名,还想更改 saveAction()方法中的表名吗?

我正在等待你的回应......

1 个答案:

答案 0 :(得分:1)

这是您更改的型号名称,如果您想更改表名,请转到config.xml并搜索

然后替换该表中的参数 来自

<table>banner</table>

<table>chilly_banner</table>

然后在你的模块中的任何地方,chilly table将自动使用

相关问题