-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean Expired Orders Issue #16779
Comments
Hi @magefan. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @magefan do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@magefan, thank you for your report. |
Hi, |
@magefan, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue. |
Hi, Magento Open Source v2.2.5 We encountered a very similar issue when trying to cancel an order with a coupon code applied that had been created by a Guest that later created an account to which the order had been assigned. In our case, the issue has been triggered when manually cancelling the order from the backend. As a customer ID is now assigned to this order, it is passed as a parameter to this function:
The $customerId variable then satisfies the condition below:
Then within the below function, as 1. there is no existing rule associated to the current customer ID due to the fact that the order had been placed by a Guest and that 2. the $increment variable is false due to the fact that the current order cancellation action is intended to subtract 1 use, 3. the result is that there is no data set to the object before executing the save() function:
To reproduce the issue very simply, one might place an order as a guest and then manually add a customer_id for the order in the sales_order database table. Then when trying to cancel the order from the backend, this error will be triggered. The solution proposed by @magefan which consist of executing the save() method within the conditions directly is valid as it would make sure that there will be no attempt to save an empty object under any circumstances. Solution:
|
@magefan thanks for the snippet. I had the same issue (magento 2.2.5 ) when trying to cancel one order which is in 'pending' state. I'm getting the same error. I get exactly same error when I try to cancel from order listing page, but when I try to mark the order as canceled from order view page, I get Does this update only prevents the creation of such orders or it was actually to fix the error caused at cancelling order? Thanks, |
@engcom-backlog-pb think we could get this reopened? I'm seeing this issue as well (2.2.6). It looks like there's a decent solution and set of steps to recreate the issue from @nikoelgatito above |
@adkanojia Your custom method is probably not getting picked up because the updateCustomerRuleUsages I just made the change in the base code(I know, bad), but you could potentially use a plugin to jump into the $ruleCustomer->save() and prevent the save from happening. This is a bit clunky though because save() is on the AbstractModel class used by all kinds of things. |
We're having the same issue on Magento 2.2.7. @magefan 's fix worked in our case. |
We're having the same issue on Magento 2.2.8 |
We ran into the same problem, and wasted a day coming up with the same patch. This is a clear bug with a straight forward solution. I don't understand why this was automatically closed. Note also this affects 2.3.X as well, but the code has been moved to SalesOrderAfterPlaceObserver.php. |
@engcom-backlog-pb +1 for seeing this on Magento 2.2.9 |
+1 Magento 2.2.9 |
Still a problem. 2.3.3 |
Same problem here. 2018: we are closing this issue due to inactivity. What a nightmare |
How can we get this re-opened? It's obviously still a problem.... |
And @magefan fix still worked |
This is apparently still an issue even in 2.3.5. |
This is still an issue for me. Ran a sale and cannot cancel some orders now. Magento 2.3.4, PHP 7.2.26
|
Still an issue 2.4.1 |
Still an issue 2.4.3 |
i can confirm this issue in 2.4.3-p1 |
Preconditions
When you have pending orders, from time to time magento cancel this orders. It depends on the option Pending Payment Order Lifetime (minutes) (https://prnt.sc/k5zs2m).
Magento has a cronjob sales_clean_orders to do this
Magento 2.2.4
PHP 7.0.27
Steps to reproduce
Expected result
Once Pending Payment Order Lifetime expired, magento run cron job sales_clean_orders without the issue
Actual result
Cron job status = Error
Message
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (
salesrule_customer, CONSTRAINT
SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_IDFOREIGN KEY (
rule_id) REFERENCES
salesrule(
rule_id) ON DELETE CASCADE), query was: INSERT INTO
salesrule_customer() VALUES ()
More info
We have made an investigation, and the problem is in method
\Magento\SalesRule\Model\Coupon\UpdateCouponUsages::updateCustomerRuleUsages
When order has been placed using cart rule without coupon it does not do eny set actions, so the object data before $ruleCustomer->save(); is empty array.
Our temporary sollution was to chage code like this.
Old code
The text was updated successfully, but these errors were encountered: