簡體   English   中英

Magento中針對同一模塊的不同模型:

[英]Different Models in Magento for same Module:

我在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');

    }
}

那么如何運行它以及該模型資源如何知道具有表..?

如果要向自定義模塊添加其他模型,則應在位於module / etc文件夾中的config.xml文件中輸入表名:

<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');
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM