简体   繁体   English

加入收藏查询在Magento中不起作用

[英]Join collection query not working in Magento

I have problem in join Collection in Magento. 我在Magento中加入收藏有问题。 When i echo my query there is main_table instead of product. 当我回应我的查询时,有main_table而不是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(). 以操作名称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. 任何帮助将不胜感激。

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. product表视为集合中的main_table是正常的,但是函数$this->getTable('web/web')不会返回表名。 You can try by using a static name of that table for testing. 您可以尝试使用该表的静态名称进行测试。 Or use Mage::getSingleton('core/resource')->getTableName('web/web'); 或者使用Mage::getSingleton('core/resource')->getTableName('web/web'); instead of $this->getTable('web/web') . 而不是$this->getTable('web/web')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM