加入Magento的问题

时间:2012-11-13 14:51:53

标签: php magento

Table 1
--------------
|reseller_id |
|1           |
|2           |
|3           |
|4           |
--------------

Table 2
-------------------------------
|reseller_id | merchandise_id |
|1           | 1              |
|1           | 3              |
|2           | 1              |
|2           | 4              |
|3           | 2              |
-------------------------------

select * from reseller_maps inner join reseller_merch on reseller_maps.reseller_id = reseller_merch.reseller_id;

在数据库方面为我提供了我正在寻找的东西。但是,我得到了一个

 Call to undefined method Namespace_Class_Model_Mysql4_Reseller_Collection::joinTable() 

尝试在Magento中执行$ collection-> joinTable()时。

我尝试过使用getSelect和join():

        $collection = Mage::getModel('maps/reseller');
        $collection->getSelect()
            ->join( array( 'reseller_merch'=>$this->getTable('reseller_merch')), 'reseller_maps.reseller_id= reseller_merch.reseller_id', array('reseller_merch.*'));

我正在接受:

 SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''

据我所知,这直接来自维基上的示例代码:http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento

1 个答案:

答案 0 :(得分:1)

假设您正在继承标准集合,它应该是:

$collection->getSelect()->join($this->getTable('maps/[table_entity]'), 'main_table.reseller_id= reseller_merch.reseller_id');

这假设您的实体以这种方式命名。