在Magento 1.8中将Use Flat Catalog Product设置为Yes时出错。我的一个模块似乎与此功能不兼容。请参阅以下错误:
a:5:{i:0; s:1852:“SELECT SUM(order_items.qty_ordered)AS
ordered_qty
,order_items
。name
ASorder_items_name
,order_items
。product_id
ASentity_id
,e
。entity_type_id
,e
。attribute_set_id
,e
。type_id
,e
。sku
,e
。has_options
,e
。required_options
,e
。created_at
,e
。updated_at
,flat
。name
,flat
。image
ASsmall_image
,flat
。price
,flat
。minimal_price
,flat
。special_price
,flat
。special_from_date
,flat
。special_to_date
,cat_index
。position
AScat_index_position
,at_inventory_in_stock
。is_in_stock
ASinventory_in_stock
FROMsales_flat_order_item
ASorder_items
INNER JOINsales_flat_order
ASorder
ONorder
。entity_id = order_items.order_id ANDorder
。state<> '取消'和 (order
。created_at BETWEEN'2014-01-18'''2014-02-17')LEFT JOINcatalog_product_entity
ASe
ON(e.type_id NOT IN('groups', 'configurable','bundle'))和e.entity_id = order_items.product_id AND e.entity_type_id = 4 LEFT JOINcatalog_product_flat_1
ASflat
ON(e.entity_id = flat.entity_id)INNER JOINcatalog_category_product_index
AScat_index
ON cat_index.product_id = e.entity_id AND cat_index.store_id ='1'AND cat_index.visibility IN(2,4)AND cat_index.category_id ='2'INNER 加入cataloginventory_stock_item
ASat_inventory_in_stock
ON (at_inventory_in_stock。product_id
= e.entity_id)AND ((at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock = 1 AND at_inventory_in_stock.is_in_stock = 1)或 (at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock = 0)或 (at_inventory_in_stock.use_config_manage_stock = 1 AND at_inventory_in_stock.is_in_stock = 1))WHERE(parent_item_id IS NULL) GROUP BYorder_items
。product_id
HAVING (SUM(order_items.qty_ordered)> 0)ORDER BYordered_qty
desc,ordered_qty
desc LIMIT 1“; I:1; S:4869:” #0 /home2/icast.sajtpro.se/www/mxfoto/magento/includes/src/Varien_Db_Statement_Pdo_Mysql.php(110): Zend_Db_Statement_Pdo-> _execute(阵列)
在list.phtml文件中,我有以下代码:
class Tatva_Catalogextensions_Block_Bestsellers_List extends Mage_Catalog_Block_Product_List {
protected function _getProductCollection()
{
parent::__construct();
$storeId = Mage::app()->getStore()->getId();
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*') ->addOrderedQty()
->setStoreId($storeId)
->addStoreFilter($storeId)
//->setOrder('ordered_qty', 'desc')
->setPageSize($this->get_prod_count())
->setOrder($this->get_order(), $this->get_order_dir())
->setCurPage($this->get_cur_page());
$productFlatData = Mage::getStoreConfig('catalog/frontend/flat_catalog_product'); if($productFlatData == "1") { $products->getSelect()->joinLeft(
array('flat' => 'catalog_product_flat_1'),
"(e.entity_id = flat.entity_id ) ",
array(
'flat.name AS name','flat.image AS small_image','flat.price AS price','flat.minimal_price as minimal_price','flat.special_price as special_price','flat.special_from_date AS special_from_date','flat.special_to_date AS special_to_date'
)
); }
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($products);
$this->_productCollection = $products;
return $this->_productCollection;
}
function get_prod_count() { //unset any saved limits
Mage::getSingleton('catalog/session')->unsLimitPage();
return (isset($_REQUEST['limit'])) ? intval($_REQUEST['limit']) : 9; }// get_prod_count
function get_cur_page() { return (isset($_REQUEST['p'])) ? intval($_REQUEST['p']) : 1; }// get_cur_page
function get_order() { return (isset($_REQUEST['order'])) ? ($_REQUEST['order']) : 'ordered_qty'; }// get_order
function get_order_dir() { return (isset($_REQUEST['dir'])) ? ($_REQUEST['dir']) : 'desc'; }// get_direction }
?>
有人可以帮帮我吗?
答案 0 :(得分:0)
你应该改变
$products = Mage::getResourceModel('reports/product_collection')
为:
$products = Mage::getResourceModel('reports/product_sold_collection')