Reputation: 1025
I have problem in join Collection in Magento. When i echo my query there is main_table instead of product. Here is my query and
SELECT `main_table`.*, `cat`.`name` FROM `product` AS `main_table` INNER JOIN `` AS `cat` ON product.cat_id = cat.id
Block with Action name getProductData().
public function getProductData()
{
$collection = Mage::getModel('web/product')->getCollection();
$collection->getSelect()->joinInner( array('cat'=>$this->getTable('web/web')), 'product.cat_id = cat.id', array('name'));
//echo $collection->getSelect(); die;
return $collection;
}
What i need to change in that action ? Any help will be appreciated.
Upvotes: 0
Views: 812
Reputation: 919
That's normal to consider the product
table as main_table
in collection but your function $this->getTable('web/web')
is not returning the table name. You can try by using a static name of that table for testing. Or use Mage::getSingleton('core/resource')->getTableName('web/web');
instead of $this->getTable('web/web')
.
Upvotes: 1