Prestashop: Products in orders disappear when catalog product is deleted

Created on 17 Dec 2019  路  11Comments  路  Source: PrestaShop/PrestaShop

Latest PS version and bellow: Products in orders disappear when catalog product is deleted. Product array in client order details is empty. File Orders.php > getCartProducts() $product['product_id'] comparision with $product['id_product'] which no longer exists.. comparision failing to empty array.

1.7.5.2 1.7.6.2 Bug FO Fixed Minor Order PR available Products

Most helpful comment

All 11 comments

Hi @danielducu,

Could you please add steps to reproduce the issue in a new comment
I attached a screen record
https://drive.google.com/file/d/1wRTm_xhV8t821rxrwux0UnJxA5XuHnXl/view
Thanks to check & feedback.

@danielducu, thanks for these clarifications.
I manage to reproduce the issue with PS1.7.5.2 & PS1.7.6.2.
In the FO => NOK
image
In the BO => OK
image
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!

Latest PS version and bellow: Products in orders disappear when catalog product is deleted. Product array in client order details is empty. File Orders.php > getCartProducts() $product['product_id'] comparision with $product['id_product'] which no longer exists.. comparision failing to empty array.

@danielducu Thank you for directly pointing the right function that creates the issue. However, $product['id_product'] exists. It is equal to NULL for a deleted product, which makes the $key string not complete and consequently the in_array returns false.

It is $product['product_id'] that should be used, please to look at the PR.

Latest PS version and bellow: Products in orders disappear when catalog product is deleted. Product array in client order details is empty. File Orders.php > getCartProducts() $product['product_id'] comparision with $product['id_product'] which no longer exists.. comparision failing to empty array.

@danielducu Thank you for directly pointing the right function that creates the issue. However, $product['id_product'] exists. It is equal to NULL for a deleted product, which makes the $key string not complete and consequently the in_array returns false.

It is $product['product_id'] that should be used, please to look at the PR.

Yeah, I was just pointing to where the comparison was failing. I fixed the issue for my version.

Thanks @arouiadib for your work ! Unfortunately, as this issue was already here before 1.7.6, we won't be able to fix it in a patch version, but I hope in the 1.7.7 version ! Would you be able to make this PR on the develop branch ?

Have a nice evening :)

@colinegin , Thank you very much.

To be honest, I am confused :). I will re-open the PR I made on develop.

In the meantime, I will try to understand how to target the appropriate branch in the future ( still a newbie in branching )

Have a nice evening you too :)

To be honest, I am confused :)

In patch versions, we only aim to fix bugs which have been introduced into the minor version.

So in 1.7.6.2 or 1.7.6.3 we aim to fix issues that have been introduced with 1.7.6 minor version.
If a bug was there for a longer time, we patch it in next minor version.

This is to ensure that the scope of a minor version stays focused and more maintainable.

So

  • if the bug was introduced in 1.7.6 (= in previous versions the bug does not exist), we fix it in 1.7.6 patch version
  • if the bug was there since longer, we fix it in next minor version 1.7.7.0

@matks :) . Thank you very much for the explanations. Priceless they are.

I see now why a solution has to be on the develop branch. I will close PR on 1.7.6.x and try to enhance the other one (at least for Travis).

Thanks @arouiadib, my mistake I should have explained better ! :-)

Was this page helpful?
0 / 5 - 0 ratings