Jump to content
don@ptg

[Bug] 1.6.1 .1 & 1.6.1.2 classes/stock/StockAvailable.php

Recommended Posts

There is a thread here that already deals with this but I thought that maybe it had gone unnoticed since the newest version of PrestaShop still has the problem. https://www.prestashop.com/forums/topic/465898-error-al-crear-pedido-manual-solucionado/

The our web site was originally launched on 1.6.1.0. The 1.6.1.1 upgrade broke the payment proccess, and we had the same fault with the upgrade to 1.6.1.2 this morning.  We have the USA Epay Module from Presto-Chango installed as our only payment module. 

When the classes/stock/StockAvailable.php is left as is some products would cause the payment window to hang and the page will never redirect. I turned on developer mode to get this error. 

 

Fatal error: Uncaught exception 'PrestaShopException' with message 'Property StockAvailable->id_product_attribute is empty' in /home/ptg/public_html/classes/ObjectModel.php:909 Stack trace: #0 /home/ptg/public_html/classes/ObjectModel.php(246): ObjectModelCore->validateFields() #1 /home/ptg/public_html/classes/ObjectModel.php(652): ObjectModelCore->getFields() #2 /home/ptg/public_html/classes/stock/StockAvailable.php(406): ObjectModelCore->update(false) #3 /home/ptg/public_html/Core/Business/Stock/Core_Business_Stock_StockManager.php(128): StockAvailableCore->update() #4 /home/ptg/public_html/classes/stock/StockAvailable.php(472): Core_Business_Stock_StockManager->updateQuantity(Object(Product), '0', -1, NULL) #5 /home/ptg/public_html/classes/order/OrderDetail.php(473): StockAvailableCore::updateQuantity('577', '0', -1) #6 /home/ptg/public_html/classes/order/OrderDetail.php(638): OrderDetailCore->checkProductStock(Array, '2') #7 /home/ptg/public_html/classes/order/OrderDetail.php(678): OrderDetailCore->create(Object(Order in/home/ptg/public_html/classes/ObjectModel.php on line 909

 

Replacing the classes/stock/StockAvalible.php file with the one from 1.6.1.0 seems to have solved the problem. For both of the newer versions. 

 

It does seem to be fixed, but if this is not the correct way to solve the problem, then I would appreciate the feedback. The other thread is difficult for me to follow since I do not read any other language. Google translate seems to help though. 

Edited by don@ptg (see edit history)

Share this post


Link to post
Share on other sites

I don´t have this folder or file in the core/business folder. Any help?

I looked in our live site and the downloaded version and the folders and file is there. I am still using the solution I stated in the first post and our site is processing $6000 - $12000 USD a day in sales. I do plan on using Zmacedoni's kind fix soon though.  :)

Share this post


Link to post
Share on other sites

The solution proposed by "zmacedoni" solved the same issue I was experiencing with "cancelling" an order in Prestashop 1.6.1.3!
Thank you for the support!

Edited by The Devils Parts (see edit history)

Share this post


Link to post
Share on other sites

Hi,

 

Be careful, this bug is still occur in 1.6.1.3 version !

 

Thank you for resolve this problem !

 

Peter

  • Like 1

Share this post


Link to post
Share on other sites

It is a bug in file Core/Business/Stock/Core_Business_Stock_StockManager.php at line 126

 

you should have like this:

 

 

$stockAvailable->quantity = $stockAvailable->quantity + $delta_quantity;

$stockAvailable->id_product = (int)$product->id;

$stockAvailable->id_product_attribute = (int)$id_product_attribute;

$stockAvailable->update();

I'm using PrestaShop 1.6.1.4, NOT using multishop. The symptom that I was trying to treat was an error message when trying to place an order "Cart cannot be loaded or an order has already been placed using this cart". When debugging on my localhost, I got "[PrestaShopException] Property StockAvailable->id_product_attribute is empty - at line 909 in file classes/ObjectModel.php".

 

My ps_stock_availability table (which several people indicated as the base problem) was fine.

 

Applying the fix above solved the problem for me.

 

Prior to the "Cart cannot be loaded or an order has already been placed using this cart", on the same customer, we first got a PayPal error "Error Occured" with a lot of into, but with PAYMENTREQUESTINFO_0_ERRORCODE  = 0. We also had an order from the customer placed which had the correct total, tax etc., but which had no products in the basket. We then starting running into the problem when making a new order for the customer. These other problems may also be related... in any case, our EXCELLENT customer support was still able to land the sale (thanks, Susana!).

 

THANKS, zmacedoni!

 

NOTE: There is an open issue on this in Forge... I've added my upvote and my details: http://forge.prestashop.com/browse/PSCSX-6890

Edited by EdEichman (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Note that there are two versions of "Cart cannot be loaded or an order has already been placed using this cart". One of them is what appears to be a benign warning (coming from FrontController and marked as warning level 1 (informative only)) that a new cart is being generated after an order is placed. https://www.prestashop.com/forums/topic/466782-cart-cannot-be-loaded-or-an-order-has-already-been-placed-using-this-cart/page-3 suggests a fix for that one, but it appears to be more on an annoyance in the logs than a real problem.

 

The other is a level 4 (major issue - crash!) generated by the PaymentModule. That is the one that I was having related to this bug.

 

The fact that the text for both is the same is confusing, so I though I would mention it.

  • Like 1

Share this post


Link to post
Share on other sites

I saw the same code in 1.6.1.4 version.

 

Best,

Peter

 

still here in 1.6.1.4

 

is there a reason you call a version stable but its buggy as hell?

Share this post


Link to post
Share on other sites

Thank you, it's solved my troubles too !

Share this post


Link to post
Share on other sites

Thans from me too, it solve problems

 

ps 1.6.14

Share this post


Link to post
Share on other sites

Hi all,

 

it seems, that I got the issue...I use advance stock management...and it isn't possible to place orders via PayPal Payment, the order isn't set within prestashop. I tried to edit the file mentioned...but it doesn't work.

Do I need the empty cache or someting else?

I tried to switch from advance stock management to manual edit and I was able to place the order with paypal...so I think this is the problem...but how can I fix it.

Thanks.

Share this post


Link to post
Share on other sites

Hello,

 

I tried this fix and hoping that it worked - it works on my test order but the real test will be if someone else places orders now. 

 

Can you please tell me if it is possible to retrieve in the database the products that belonged to those blank orders to make up the totals of the orders? 

 

Thank you in advance.

 

Regards,

Jhorene

Share this post


Link to post
Share on other sites

Hello,

 

I tried this fix and hoping that it worked - it works on my test order but the real test will be if someone else places orders now. 

 

Can you please tell me if it is possible to retrieve in the database the products that belonged to those blank orders to make up the totals of the orders? 

 

Thank you in advance.

 

Regards,

Jhorene

What we did on the blank orders, is look at the customers cart. The products were still there and it helped us recover the orders. 

Share this post


Link to post
Share on other sites

There is a thread here that already deals with this but I thought that maybe it had gone unnoticed since the newest version of PrestaShop still has the problem. https://www.prestashop.com/forums/topic/465898-error-al-crear-pedido-manual-solucionado/

The our web site was originally launched on 1.6.1.0. The 1.6.1.1 upgrade broke the payment proccess, and we had the same fault with the upgrade to 1.6.1.2 this morning.  We have the USA Epay Module from Presto-Chango installed as our only payment module. 

When the classes/stock/StockAvailable.php is left as is some products would cause the payment window to hang and the page will never redirect. I turned on developer mode to get this error. 

 

Fatal error: Uncaught exception 'PrestaShopException' with message 'Property StockAvailable->id_product_attribute is empty' in /home/ptg/public_html/classes/ObjectModel.php:909 Stack trace: #0 /home/ptg/public_html/classes/ObjectModel.php(246): ObjectModelCore->validateFields() #1 /home/ptg/public_html/classes/ObjectModel.php(652): ObjectModelCore->getFields() #2 /home/ptg/public_html/classes/stock/StockAvailable.php(406): ObjectModelCore->update(false) #3 /home/ptg/public_html/Core/Business/Stock/Core_Business_Stock_StockManager.php(128): StockAvailableCore->update() #4 /home/ptg/public_html/classes/stock/StockAvailable.php(472): Core_Business_Stock_StockManager->updateQuantity(Object(Product), '0', -1, NULL) #5 /home/ptg/public_html/classes/order/OrderDetail.php(473): StockAvailableCore::updateQuantity('577', '0', -1) #6 /home/ptg/public_html/classes/order/OrderDetail.php(638): OrderDetailCore->checkProductStock(Array, '2') #7 /home/ptg/public_html/classes/order/OrderDetail.php(678): OrderDetailCore->create(Object(Order in/home/ptg/public_html/classes/ObjectModel.php on line 909

 

Replacing the classes/stock/StockAvalible.php file with the one from 1.6.1.0 seems to have solved the problem. For both of the newer versions. 

 

It does seem to be fixed, but if this is not the correct way to solve the problem, then I would appreciate the feedback. The other thread is difficult for me to follow since I do not read any other language. Google translate seems to help though. 

 

Worked!!! Thank you, it was making me mad!

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More