0

I want to make join on my custom module collection to product collection.In my module there is a single table which have product sku and product url key.Now I want all catalog product data as well as my module data below is the code which i am using but it's not working :

$collection = Mage::getModel("catalog/product")->getCollection();
                $msa_eventType = Mage::getSingleton('core/resource')->getTableName('preview/preview');              
                $collection->getSelect()->joinLeft(array('review'=>$msa_eventType),'`main_table`.`sku` = `review`.`sku`',array('product_name')); 
  • first check $msa_eventType return table value or not? – Rakesh Jesadiya Oct 12 '16 at 13:40
  • Add echo $collection->getSelect(); die; after Join and share the SQL generated by magento. – Nidheesh Oct 12 '16 at 14:52
1

Remove ` from your query,

'`main_table`.`sku` = `review`.`sku`'

Replace it with

'main_table.sku = review.sku'

Final code,

$collection = Mage::getModel("catalog/product")->getCollection();
$msa_eventType = Mage::getSingleton('core/resource')->getTableName('preview/preview');              
$collection->getSelect()->joinLeft(array('review'=>$msa_eventType),'main_table.sku = review.sku',array('product_name')); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.