Magento中不同型号的相同模块:

时间:2011-06-20 10:49:50

标签: magento collections model

我在Magento中创建了一个模块,现在我想使用其他模型来收集,但那会给我错误,

**Error:** There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 1685082734

我的Collection类在下面给出..

class Mage_Banners_Model_Mysql4_Category_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract

{

    public function _construct()

    { 
        parent::_construct();

        $this->_init('banners/category');

    }
}

那么如何运行这个以及这个模型资源如何知道有表..?

1 个答案:

答案 0 :(得分:1)

如果要将另一个模型添加到自定义模块,则应在config.xml文件中输入表名,该文件位于yourmodule / etc文件夹中:

<entities>
<banners>
    <table>Your table Name here</table>
</banners>

之后,您应该在相应的model/mysql4/category/Collection.php中添加您的集合类。您应该在模型/文件名中创建模型类。

假设category.php是模型文件,您应该使用这些方法启动该模型类。这些文件应位于model文件夹中:

public function _construct()
{    
    // Note that the category_id refers to the key field in your database table.
    $this->_init('banner/category', 'category_id');
}