Skip to content

Wrong SQL query for _getProductCollection() on Bippo_MostViewedProducts_Block_List.php(61) #1

@ceefour

Description

@ceefour

Kalau flat catalog product diaktifkan ( wiz config-defaultset catalog/frontend/flat_catalog_product 1 ) maka error. Jika tidak aktif, jalan.

URL: http://www.littlestarshop.com/ IP Address: 110.136.132.252 Time: 2012-05-06 14:38:08 GMT Error:

SELECT COUNT(report_table_views.event_id) AS views, e.*, e.entity_id, e.attribute_set_id, e.type_id, e.color, e.color_value, e.cost, e.created_at, e.enable_googlecheckout, e.has_options, e.image_label, e.is_recurring, e.links_exist, e.links_purchased_separately, e.links_title, e.name, e.news_from_date, e.news_to_date, e.price, e.price_type, e.price_view, e.recurring_profile, e.required_options, e.shipment_type, e.short_description, e.size, e.size_value, e.sku, e.sku_type, e.small_image, e.small_image_label, e.special_from_date, e.special_price, e.special_to_date, e.tax_class_id, e.thumbnail, e.thumbnail_label, e.updated_at, e.url_key, e.url_path, e.visibility, e.weight, e.weight_type, e.custom_design_from, e.custom_design_to, e.custom_layout_update, e.description, e.gallery, e.gift_message_available, e.image, e.is_imported, e.manufacturer, e.manufacturer_value, e.media_gallery, e.meta_description, e.meta_keyword, e.meta_title, e.minimal_price, e.msrp, e.msrp_display_actual_price_type, e.msrp_enabled, e.old_id, e.item_color, e.item_color_value, e.item_size, e.item_size_value FROM report_event AS report_table_views
INNER JOIN catalog_product_entity AS e ON e.entity_id = report_table_views.object_id AND e.entity_type_id = 4 WHERE (report_table_views.event_type_id = 1) GROUP BY e.entity_id HAVING (COUNT(report_table_views.event_id) > 0) ORDER BY views DESC LIMIT 9

Trace: #0 /home/magento/sites/littlestar/includes/src/Varien_Db_Statement_Pdo_Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #1 /home/magento/sites/littlestar/includes/src/__default.php(61458): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #2 /home/magento/sites/littlestar/includes/src/__default.php(51202): Zend_Db_Statement->execute(Array) #3 /home/magento/sites/littlestar/includes/src/__default.php(52238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(re…', Array) #4 /home/magento/sites/littlestar/includes/src/__default.php(53044): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(re…', Array) #5 /home/magento/sites/littlestar/includes/src/__default.php(51457): Varien_Db_Adapter_Pdo_Mysql->query('SELECT COUNT(re…', Array) #6 /home/magento/sites/littlestar/includes/src/__default.php(30597): Zend_Db_Adapter_Abstract->fetchAll('SELECT COUNT(re…', Array) #7 /home/magento/sites/littlestar/includes/src/Mage_Eav_Model_Entity_Collection_Abstract.php(1045): Varien_Data_Collection_Db->_fetchAll('SELECT COUNT(re…') #8 /home/magento/sites/littlestar/includes/src/Mage_Eav_Model_Entity_Collection_Abstract.php(869): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false) #9 /home/magento/sites/littlestar/includes/src/Bippo_MostViewedProducts_Block_List.php(61): Mage_Eav_Model_Entity_Collection_Abstract->load() #10 /home/magento/sites/littlestar/includes/src/Mage_Catalog_Block_Product_List.php(141): Bippo_MostViewedProducts_Block_List->_getProductCollection() #11 /home/magento/sites/littlestar/includes/src/__default.php(2499): Mage_Catalog_Block_Product_List->_beforeToHtml() #12 /home/magento/sites/littlestar/includes/src/__default.php(12952): Mage_Core_Block_Abstract->toHtml() #13 /home/magento/sites/littlestar/includes/src/__default.php(2500): Mage_Core_Block_Text_List->_toHtml() #14 /home/magento/sites/littlestar/includes/src/__default.php(2219): Mage_Core_Block_Abstract->toHtml() #15 /home/magento/sites/littlestar/includes/src/__default.php(2163): Mage_Core_Block_Abstract->_getChildHtml('content', true) #16 /home/magento/sites/littlestar/app/design/frontend/default/f002/template/page/3columns.phtml(55): Mage_Core_Block_Abstract->getChildHtml('content') #17 /home/magento/sites/littlestar/includes/src/__default.php(3205): include('/home/magento/s…') #18 /home/magento/sites/littlestar/includes/src/__default.php(3236): Mage_Core_Block_Template->fetchView('frontend/defaul…') #19 /home/magento/sites/littlestar/includes/src/__default.php(3250): Mage_Core_Block_Template->renderView() #20 /home/magento/sites/littlestar/includes/src/__default.php(2500): Mage_Core_Block_Template->_toHtml() #21 /home/magento/sites/littlestar/includes/src/__default.php(26970): Mage_Core_Block_Abstract->toHtml() #22 /home/magento/sites/littlestar/includes/src/__default.php(13346): Mage_Core_Model_Layout->getOutput() #23 /home/magento/sites/littlestar/includes/src/__default.php(10710): Mage_Core_Controller_Varien_Action->renderLayout() #24 /home/magento/sites/littlestar/includes/src/__default.php(10630): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), ‘home’) #25 /home/magento/sites/littlestar/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), ‘home’) #26 /home/magento/sites/littlestar/includes/src/__default.php(13375): Mage_Cms_IndexController->indexAction() #27 /home/magento/sites/littlestar/includes/src/__default.php(17632): Mage_Core_Controller_Varien_Action->dispatch('index') #28 /home/magento/sites/littlestar/includes/src/__default.php(17222): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #29 /home/magento/sites/littlestar/includes/src/__default.php(19715): Mage_Core_Controller_Varien_Front->dispatch() #30 /home/magento/sites/littlestar/app/Mage.php(640): Mage_Core_Model_App->run(Array) #31 /home/magento/sites/littlestar/index.php(83): Mage::run('default', ‘store’) #32 {main}

Query tsb memang salah, kalo dijalanin hasilnya:

ERROR 1054 (42S22): Unknown column 'e.color' in 'field list'

Harusnya query tersebut pakai tabel catalog_product_flat_# dan bukannya catalog_product_entity

Selidik punya selidik, ternyata ini yang bikin masalah : Bippo_MostViewedProducts_Block_List.php(61)

protected function _getProductCollection()
{
    $storeId = Mage::app()->getStore()->getStoreId();
    $this->setStoreId($storeId);
    if (is_null($this->_productCollection)) {
        $this->_productCollection = Mage::getResourceModel('reports/product_collection');

        if ($this->getTimeLimit()) {
            $product = Mage::getModel('catalog/product');
            $todayDate = $product->getResource()->formatDate(time());
            $startDate = $product->getResource()->formatDate(time() - 60 * 60 * 24 * $this->getTimeLimit());
            $this->_productCollection = $this->_productCollection->addViewsCount($startDate, $todayDate);
        } else {
            $this->_productCollection = $this->_productCollection->addViewsCount();
        }        
        $statuses = Mage::getSingleton('catalog/product_status')->getVisibleStatusIds();
        $this->_productCollection = $this->_productCollection->addAttributeToSelect('*')
                        ->setStoreId($storeId)
                        ->addStoreFilter($storeId)
                        ->addAttributeToFilter('status', $statuses)
                        ->setPageSize($this->getToolbarBlock()->getLimit());

    }
    $this->_productCollection->load();
    return $this->_productCollection;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions