Magento Collection Unites Between Different Modules

I am working on a custom module with an admin backend. So far, it worked just fine, like the client modules, but now I'm stuck with this. My user table saves the client ID, and I can show the client name on each grid line. While I can show the ID, I know that I should prepare the collection, but I have no clue. If I use union, it only works for models of the same module. I tried this:

$collection = Mage::getModel('mymodule/mymodel')->getCollection()->getSelect() ->join( 'customer_entity', 'main_table.customer_id = customer_entity.entity_id', array('customer_name' => 'email')); 

If I print a request, it looks like

 SELECT `main_table`.*, `customer_entity`.`email` AS `customer_name` FROM `uhma_comunidad_question` AS `main_table` INNER JOIN `customer_entity` ON main_table.customer_id = customer_entity.entity_id 

but returns nothing, the collection is null, if I copy this sql and paste it into phpmyadmin, it works fine, that I'm missing here

Thanks for the help.

+4
source share
2 answers

just if you use the chain for getSelect (), it didn’t work, just added another line

 $collection = Mage::getModel('mymodule/mymodel')->getCollection(); $collection->getSelect() ->join( 'customer_entity', 'main_table.customer_id = customer_entity.entity_id', array('customer_name' => 'email')); 

it works great

+9
source
 $collection = Mage::getModel('mymodule/mymodel')->getCollection()->getSelect() ->join( 'customer_entity', 'main_table.customer_id = customer_entity.entity_id', array('customer_name' => 'email')); 
+1
source

All Articles