Jump to content

Sale Fails To Complete When Item Has 0 Qty Onhand


stevell

Recommended Posts

I am having an issue with sales not completing.

It fails and does not add all the items to ps_order_detail. Sometimes there are a few items in the table but it appears to stop on the item with a onhand value of 0 

Depending on where it fails, it may not populate the ps_carrier, ps_ invoice, ps_payment

 

I have stock management and advanced stock management disabled. Prestashop does however appear to continue to count the stock and some of our items are negative by hundreds. eg -150 

 

Prestashop version 1.6.1.3

 

There are no errors in the prestashop error log, or the server logs ) including the Mysql log. 

 

Some times it happens every few sales or it can be dozens of sales between crashes. The only thing that apears to be in common is the fact that one of the items in the cart is at 0 onhand and it generally does not write that item to the tables

 

Update

I have been able to duplicate the error with a sale with error reporting on.

 

Fatal error: Uncaught exception 'PrestaShopException' with message 'Property StockAvailable->id_product_attribute is empty' in /home/xxx/public_html/classes/ObjectModel.php:909

Stack trace:

#0 /home/xxx/public_html/classes/ObjectModel.php(246): ObjectModelCore->validateFields()

#1 /home/xxx/public_html/classes/ObjectModel.php(652): ObjectModelCore->getFields()

#2 /home/xxx/public_html/classes/stock/StockAvailable.php(406): ObjectModelCore->update(false)

#3 /home/xxx/public_html/Core/Business/Stock/Core_Business_Stock_StockManager.php(128): StockAvailableCore->update()

#4 /home/xxxpublic_html/classes/stock/StockAvailable.php(472): Core_Business_Stock_StockManager->updateQuantity(Object(Product), '0', -1, NULL)

#5 /home/xxx/public_html/classes/order/OrderDetail.php(473): StockAvailableCore::updateQuantity('226', '0', -1)

#6 /home/xxx/public_html/classes/order/OrderDetail.php(638): OrderDetailCore->checkProductStock(Array, '2')

#7 /home/xxx/public_html/classes/order/OrderDetail.php(678): in /home/xxx/public_html/classes/ObjectModel.php on line 909

 

 

It appears it is not caused by the 0 quantity but that there are products which do not have a corresponding entry in the ps_stock_available table. Prestashop sees it as 0 quantity in stock because there is no record in the table. Prestashop still tries to update the quantity in stock despite the fact that stock management is disabled.  The products are a bit older & have been in the database for a couple of years so could be from a bug in an earlier PS version. I assume earlier versions of prestashop prior to 1.6 did not check or use this table when stock management is turned off as it has worked fine prior to upgrading to 1.6. 

It seems a waste of time checking the onhand quantity when stock management is disabled. 

 

I will need to write an sql to fill in the holes in the ps_stock_available table.

 

I have seen a few other posts regarding the same issue so I hope this helps someone else.

 

Thanks

Steve

Edited by stevell (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...