繁体   English   中英

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

[英]Join collection query not working in Magento

我在Magento中加入收藏有问题。 当我回应我的查询时,有main_table而不是product。 这是我的查询和

SELECT `main_table`.*, `cat`.`name` FROM `product` AS `main_table` INNER JOIN `` AS `cat` ON product.cat_id = cat.id

以操作名称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;
}

在该操作中我需要更改什么? 任何帮助将不胜感激。

product表视为集合中的main_table是正常的,但是函数$this->getTable('web/web')不会返回表名。 您可以尝试使用该表的静态名称进行测试。 或者使用Mage::getSingleton('core/resource')->getTableName('web/web'); 而不是$this->getTable('web/web')

暂无
暂无

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

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