0
votes

I have two exactly same sites, one is on local machine and one is live. When I'm trying to get best products into right sidebar the one that is on local machine is working fine but the live site throws the following error

a:5:{i:0;s:2382:"SELECT SUM(order_items.qty_ordered) AS `ordered_qty`, `order_items`.`name` AS `order_items_name`, `order_items`.`product_id` AS `entity_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`, `e`.`entity_id`, `e`.`attribute_set_id`, `e`.`type_id`, `e`.`cost`, `e`.`created_at`, `e`.`enable_googlecheckout`, `e`.`gift_message_available`, `e`.`has_options`, `e`.`image_label`, `e`.`is_imported`, `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`.`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`.`msrp`, `e`.`msrp_display_actual_price_type`, `e`.`msrp_enabled`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `e`.`name`, `e`.`price`, `e`.`small_image`, `cat_index`.`position` AS `cat_index_position` FROM `sales_flat_order_item` AS `order_items`
 INNER JOIN `sales_flat_order` AS `order` ON `order`.entity_id = order_items.order_id AND `order`.state  'canceled'
 LEFT JOIN `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
 INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `catalog_category_product_index` AS `cat_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' WHERE (parent_item_id IS NULL) GROUP BY `order_items`.`product_id` HAVING (SUM(order_items.qty_ordered) > 0) ORDER BY `ordered_qty` desc LIMIT 9

";i:1;s:5232:"#0 /var/www/vhosts/.../httpdocs/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

#1 /var/www/vhosts/.../httpdocs/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)

#2 /var/www/vhosts/.../httpdocs/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)

#3 /var/www/vhosts/.../httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT SUM(orde...', Array)

#4 /var/www/vhosts/.../httpdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT SUM(orde...', Array)

#5 /var/www/vhosts/.../httpdocs/lib/Zend/Db/Adapter/Abstract.php(734): Varien_Db_Adapter_Pdo_Mysql->query('SELECT SUM(orde...', Array)

#6 /var/www/vhosts/.../httpdocs/lib/Varien/Data/Collection/Db.php(734): Zend_Db_Adapter_Abstract->fetchAll('SELECT SUM(orde...', Array)

#7 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(1047): Varien_Data_Collection_Db->_fetchAll('SELECT SUM(orde...')

#8 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(871): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false)

#9 /var/www/vhosts/.../httpdocs/lib/Varien/Data/Collection.php(752): Mage_Eav_Model_Entity_Collection_Abstract->load()

#10/var/www/vhosts/.../httpdocs/app/design/frontend/default/ma_pharmacy/template/magentothem/bestsellerproductvertscroller/bestsellerright.phtml(42): Varien_Data_Collection->count()

#11 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/vhosts...')

#12 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')

#13 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()

#14 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Abstract.php(886): Mage_Core_Block_Template->_toHtml()

#15 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()

#16 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Abstract.php(886): Mage_Core_Block_Text_List->_toHtml()

#17 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Abstract.php(605): Mage_Core_Block_Abstract->toHtml()

#18 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Abstract.php(549): Mage_Core_Block_Abstract->_getChildHtml('right', true)

#19 /var/www/vhosts/.../httpdocs/app/design/frontend/default/ma_pharmacy/template/page/2columns-right.phtml(59): Mage_Core_Block_Abstract->getChildHtml('right')

#20 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/vhosts...')

#21 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')

#22 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()

#23 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Block/Abstract.php(886): Mage_Core_Block_Template->_toHtml()

#24 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()

#25 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()

#26 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Cms/Helper/Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()

#27 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')

#28 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')

#29 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()

#30/var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')

#31 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))

#32 /var/www/vhosts/.../httpdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()

#33 /var/www/vhosts/.../httpdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)

#34 /var/www/vhosts/.../httpdocs/index.php(87): Mage::run('', 'store')

#35 {main}";s:3:"url";s:1:"/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

I don't quite understand where is the problem. Would appreciate some help, where should I look.

Thanks a lot.

2
in the first place , why are you using manual query and not magento's ORM.magentocommerce.com/knowledge-base/entry/…huzefam
I'm not using manual query.The theme requesting products via Mage_Catalog_Block_Product_Abstract public function getProducts () { $products = Mage::getResourceModel('reports/product_collection') .....}Revenko Igor
in your file app/design/frontend/default/ma_pharmacy/template/magentothem/bestsellerproductvertscroller/bestsellerright.phtml , check what result is getting returned.huzefam
somehow the problem is in ->addOrderedQty() and ->setOrder('ordered_qty', 'desc') once I removed it everything started to work. May be anyone has some thoughts regarding this issue?Revenko Igor
Why downvote? How is it unclear or not useful?Revenko Igor

2 Answers

2
votes

use this steps

system->config->catalog->frontend

set Use Flat Catalog Category, Use Flat Catalog Product both to no.

It works for me.

0
votes

As I said above the issue was in ->addOrderedQty() and ->setOrder('ordered_qty', 'desc') the fix can be found here Magento 1.7 sorting by ordered quantity - bestseller products issues