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;
Is giving me what I’m looking for on the database side of things. However, I’m getting an
Call to undefined method Namespace_Class_Model_Mysql4_Reseller_Collection::joinTable()
When trying to do $collection->joinTable() in Magento.
I’ve tried using getSelect and 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.*'));
and am getting:
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
As far as I can tell this is directly from the example code on the wiki: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/using_collections_in_magento
Assuming you’re subclassing a standard collection, it should be:
This is assuming your entities are named this way.