I'm having an issue with Magento 1.9.2.4 trying to make a join on my collection, here's the problem:
Actually I've got a custom table named product_banner which I'm getting by:
$collection = Mage::getModel('mymodule_productbanner/productbanner')->getCollection();
But I need to join this table with catalog_category_entity_varchar
, I've tried solution:
$catalogTable = Mage::getSingleton('core/resource')->getTableName('catalog/category');
$collection = Mage::getModel('exablack_productbanner/productbanner')->getCollection()->getSelect()->join(array('category' => $catalogTable),
'main_table.category_id = category.entity_id AND category.attribute_id = 41');
But for no avail... The pure sql query I need to run to get my desired result would be:
select catalog_category_entity_varchar.value, product_banner.banner_url,
product_banner.text from product_banner inner join catalog_category_entity_varchar
on product_banner.category_id = catalog_category_entity_varchar.entity_id and
catalog_category_entity_varchar.attribute_id = 41;
How can I achieve this with magento collections?