【问题标题】:Bestseller list and catalog_product_flat_1 in MagentoMagento 中的畅销书列表和 catalog_product_flat_1
【发布时间】:2014-02-18 16:09:55
【问题描述】:

在 Magento 1.8 中将使用平面目录产品设置为是时出现错误。我的一个模块似乎与此功能不兼容。看到以下错误:

a:5:{i:0;s:1852:"SELECT SUM(order_items.qty_ordered) AS ordered_qty, order_items.name AS order_items_name, order_items.product_identity_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 AS small_image, flat.price, flat.minimal_price, flat.special_price, flat.special_from_date, flat.special_to_date, cat_index.position AS cat_index_position, at_inventory_in_stock.is_in_stock AS inventory_in_stock FROM sales_flat_order_item AS order_items 内连接sales_flat_order AS order ON order.entity_id = order_items.order_id AND order.state '取消' AND (order.created_at BETWEEN '2014-01-18' AND '2014-02-17') 左加入 catalog_product_entity AS e ON (e.type_id NOT IN ('grouped', 'configurable', 'bundle')) AND e.entity_id = order_items.product_id AND e.entity_type_id = 4 左连接 catalog_product_flat_1 AS flat ON (e.entity_id = flat.entity_id) 内连接 catalog_category_product_index AS cat_index 开启 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 AS at_inventory_in_stock ON (at_inventory_in_stock.product_id=e.entity_id) 和 ((at_inventory_in_stock.use_config_manage_stock = 0 AND at_inventory_in_stock.manage_stock=1 和 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) 分组order_items.product_id有 (SUM(order_items.qty_ordered) > 0) ORDER BY ordered_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(Array)

在 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 }

?>

有人可以帮帮我吗?

【问题讨论】:

    标签: magento


    【解决方案1】:

    你应该改变

    $products = Mage::getResourceModel('reports/product_collection')
    

    到:

    $products = Mage::getResourceModel('reports/product_sold_collection')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多