簡體   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