0

edit 3: In the final review of an order in onepage checkout when the user submits the order there is an ajax request to /checkout/onepage/saveOrder/. This returns an error error: true. All I found in the logs is the error below. I can reproduce this error on another demo-shop, but the Ajax request to saveOrder does not return error: true. So my final question is, where is this error coming from.


Originalpost:

When I try to buy a product where only 1 item is left on stock I get the following error in the front-end as alert message after I press buy on the onepage checkout:

There was an error processing your order. Please contact us or try again later.

And in the exception.log i get the following:

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1' in /path/lib/Zend/Db/Statement/Pdo.php:234
Stack trace:
#0 /path/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /path/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /path/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /path/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 /path/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 /path/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price/Default.php(287): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ca...')
#6 /path/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price/Default.php(140): Mage_Catalog_Model_Resource_Product_Indexer_Price_Default->_prepareFinalPriceData(Array)
#7 /path/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Price.php(315): Mage_Catalog_Model_Resource_Product_Indexer_Price_Default->reindexEntity(Array)
#8 /path/app/code/core/Mage/CatalogInventory/Model/Observer.php(749): Mage_Catalog_Model_Resource_Product_Indexer_Price->reindexProductIds(Array)
#9 /path/app/code/core/Mage/Core/Model/App.php(1338): Mage_CatalogInventory_Model_Observer->reindexQuoteInventory(Object(Varien_Event_Observer))
#10 /path/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(Webkul_Preorder_Model_CatalogInventoryObserver), 'reindexQuoteInv...', Object(Varien_Event_Observer))
#11 /path/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('sales_model_ser...', Array)
#12 /path/app/code/local/Webkul/Preorder/Model/Sales/Service/Quote.php(97): Mage::dispatchEvent('sales_model_ser...', Array)
#13 /path/app/code/core/Mage/Sales/Model/Service/Quote.php(249): Webkul_Preorder_Model_Sales_Service_Quote->submitOrder()
#14 /path/app/code/core/Mage/Checkout/Model/Type/Onepage.php(785): Mage_Sales_Model_Service_Quote->submitAll()
#15 /path/app/code/core/Mage/Checkout/controllers/OnepageController.php(579): Mage_Checkout_Model_Type_Onepage->saveOrder()
#16 /path/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Checkout_OnepageController->saveOrderAction()
#17 /path/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#18 /path/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#19 /path/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#20 /path/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#21 /path/index.php(89): Mage::run('', 'store')
#22 {main}

The order itself is created anyway and visible in the back-end. But no mail goes to the customer.

First of all, is there any way to get the full MySQL Query? So I could at least check the database and see where it goes wrong.

Second: I am not completely sure about "only 1 item is left on stock". For now I only get this error with this products, but then when I increase the stock on this products, I still get the error.

Any hint could help! Also tips to debug this

edit: Meanwhile I have the query:

INSERT INTO `catalog_product_index_price_final_tmp` SELECT `e`.`entity_id`, `cg`.`customer_group_id`, `cw`.`website_id`, IF(IFNULL(tas_tax_class_id.value_id, -1) > 0, tas_tax_class_id.value, tad_tax_class_id.value) AS `tax_class_id`, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value) AS `orig_price`, IF(IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price) < IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value)), IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price), IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value))) AS `price`, IF(IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price) < IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value)), IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price), IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value))) AS `min_price`, IF(IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price) < IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value)), IF(gp.price IS NULL, IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), gp.price), IF(IF(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_from_date.value_id, -1) > 0, tas_special_from_date.value, tad_special_from_date.value)) <= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value) IS NULL, 1, IF(DATE(IF(IFNULL(tas_special_to_date.value_id, -1) > 0, tas_special_to_date.value, tad_special_to_date.value)) >= DATE(cwd.website_date), 1, 0)) > 0 AND IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value) < IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value), IF(IFNULL(tas_special_price.value_id, -1) > 0, tas_special_price.value, tad_special_price.value), IF(IFNULL(tas_price.value_id, -1) > 0, tas_price.value, tad_price.value))) AS `max_price`, tp.min_price AS `tier_price`, tp.min_price AS `base_tier`, gp.price AS `group_price`, gp.price AS `base_group_price` FROM `catalog_product_entity` AS `e`
 CROSS JOIN `customer_group` AS `cg`
 CROSS JOIN `core_website` AS `cw`
 INNER JOIN `catalog_product_index_website` AS `cwd` ON cw.website_id = cwd.website_id
 INNER JOIN `core_store_group` AS `csg` ON csg.website_id = cw.website_id AND cw.default_group_id = csg.group_id
 INNER JOIN `core_store` AS `cs` ON csg.default_store_id = cs.store_id AND cs.store_id != 0
 INNER JOIN `catalog_product_website` AS `pw` ON pw.product_id = e.entity_id AND pw.website_id = cw.website_id
 LEFT JOIN `catalog_product_index_tier_price` AS `tp` ON tp.entity_id = e.entity_id AND tp.website_id = cw.website_id AND tp.customer_group_id = cg.customer_group_id
 LEFT JOIN `catalog_product_index_group_price` AS `gp` ON gp.entity_id = e.entity_id AND gp.website_id = cw.website_id AND gp.customer_group_id = cg.customer_group_id
 INNER JOIN `catalog_product_entity_int` AS `tad_status` ON tad_status.entity_id = e.entity_id AND tad_status.attribute_id = 96 AND tad_status.store_id = 0
 LEFT JOIN `catalog_product_entity_int` AS `tas_status` ON tas_status.entity_id = e.entity_id AND tas_status.attribute_id = 96 AND tas_status.store_id = cs.store_id
 LEFT JOIN `catalog_product_entity_int` AS `tad_tax_class_id` ON tad_tax_class_id.entity_id = e.entity_id AND tad_tax_class_id.attribute_id = 121 AND tad_tax_class_id.store_id = 0
 LEFT JOIN `catalog_product_entity_int` AS `tas_tax_class_id` ON tas_tax_class_id.entity_id = e.entity_id AND tas_tax_class_id.attribute_id = 121 AND tas_tax_class_id.store_id = cs.store_id
 LEFT JOIN `catalog_product_entity_decimal` AS `tad_price` ON tad_price.entity_id = e.entity_id AND tad_price.attribute_id = 75 AND tad_price.store_id = 0
 LEFT JOIN `catalog_product_entity_decimal` AS `tas_price` ON tas_price.entity_id = e.entity_id AND tas_price.attribute_id = 75 AND tas_price.store_id = cs.store_id
 LEFT JOIN `catalog_product_entity_decimal` AS `tad_special_price` ON tad_special_price.entity_id = e.entity_id AND tad_special_price.attribute_id = 76 AND tad_special_price.store_id = 0
 LEFT JOIN `catalog_product_entity_decimal` AS `tas_special_price` ON tas_special_price.entity_id = e.entity_id AND tas_special_price.attribute_id = 76 AND tas_special_price.store_id = cs.store_id
 LEFT JOIN `catalog_product_entity_datetime` AS `tad_special_from_date` ON tad_special_from_date.entity_id = e.entity_id AND tad_special_from_date.attribute_id = 77 AND tad_special_from_date.store_id = 0
 LEFT JOIN `catalog_product_entity_datetime` AS `tas_special_from_date` ON tas_special_from_date.entity_id = e.entity_id AND tas_special_from_date.attribute_id = 77 AND tas_special_from_date.store_id = cs.store_id
 LEFT JOIN `catalog_product_entity_datetime` AS `tad_special_to_date` ON tad_special_to_date.entity_id = e.entity_id AND tad_special_to_date.attribute_id = 78 AND tad_special_to_date.store_id = 0
 LEFT JOIN `catalog_product_entity_datetime` AS `tas_special_to_date` ON tas_special_to_date.entity_id = e.entity_id AND tas_special_to_date.attribute_id = 78 AND tas_special_to_date.store_id = cs.store_id WHERE (e.type_id = 'simple') AND (IF(IFNULL(tas_status.value_id, -1) > 0, tas_status.value, tad_status.value)=1) AND (e.entity_id IN(1608))

This query comes when the stock falls below the value in "Notify for Quantity Below" cataloginventory/item_options/notify_stock_qty.

edit2: I tested this now on a other demoshop. I get the wrong query too (as I log the query now and write it into a txt file). But I don't get the Javascript alert box in the frontend and the order works (customer get email and all). Also I dont get an errormessage back when I want to complete the order.

1
  • We are the webkul pre order module developer if you are still facing any issue please raise your query at webkul.com/ticket . thanks
    – webkul
    Sep 10 '15 at 9:41
1

First of all, is there any way to get the full MySQL Query? So I could at least check the database and see where it goes wrong.

Yes but not with standard logging.

As you're able to reproduce the issue you can do this on your development system by using a step debugger (e.g. Xdebug) and enable an exception breakpoint for the PDOException (and just to see when caused: Zend_Db_Statement_Exception).

When it is thrown, the local scope should contain the underlying PDOStatment object, so you should be able to see the SQL query in $this->_stmt->queryString at that level. If it's a parametrized query you should find the parameters in the local scope.

If you don't want to run an Xdebug session, you can even invest more time with a far more specific outcome by activating Mysql query logging. The query log will show you the statements and parameters as well however you'll have much more problems to locate the one you're looking for as it logs all (or you conditionally enable logging). Please consult the documentation of your database server for details of query logging and configuration.

2
  • Thanks for your answer! I wanted to install Xdebug and get used to it.. but I dont get time for it :/ Anyway, I got the query now. I allready tried the Mysql query logging. But there running alot of that mysql-server and I did not had much infos about the query, so it was impossible to find the right query.
    – nbar
    Jul 30 '15 at 14:09
  • Yes query logging is very noise.
    – hakre
    Jul 30 '15 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.