我试图通过覆盖Catalog/Product/List.php来使用当前产品集合检索畅销产品
<?php
if($this->getRequest()->getParam('best')==1){
$this->_productCollection->getSelect()
->joinLeft(array('items'=>'sales_flat_order_item'), "items.product_id = e.entity_id", array('count'=>'SUM(qty_ordered)'))
->group('e.entity_id');
$this->_productCollection->getSelect()->having('SUM(items.qty_ordered) > ?',0);
return $this->_productCollection;
}
?>
Run Code Online (Sandbox Code Playgroud)
使用上面的代码我得到以下SQL错误,错误是由于having子句引起的,我怎么能在上面的代码中使用havinh子句来避免产生qty_ordered <1的结果行
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'items.qty_ordered' in 'having clause'
Run Code Online (Sandbox Code Playgroud) magento ×1