You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's probably Magento bug but hard to say and it actually doesn't matter
Steps to reproduce (*)
Create or use a Coupon Code (Shopping Cart Price Rules) and leave Uses per Customer field empty or put 0.
Use this code for order placed by Logged in User
Make sure to choose a payment method which won't create an invoice or change the order state. The order should be in pending state.
Go to admin panel and try to cancel the order
Expected result (*)
The order should be canceled
Actual result (*)
Order can not be canceled message.
Mysql Exception:
Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`open_mage`.`salesrule_customer`, CONSTRAINT `FK_SALESRULE_CUSTOMER_RULE_ID_SALESRULE_RULE_ID` FOREIGN KEY (`rule_id`) REFERENCES `salesrule` (`rule_id`) ON DELETE CASCADE ON UPDATE CASCADE) in /Volumes/Workspace/om/shop/magento/lib/Zend/Db/Statement/Pdo.php:228
Reason:
In Mage_SalesRule_Model_Observer:162 system is trying to decrease the code usage amount in salesrule_customer but there's no entity to change. Used promo rule had no limitation per user, so Magento didn't create an entry after order placement.
My solution:
It could check if the entity exists ($object->getId()) before trying to manipulate it. Mage_SalesRule_Model_Observer:162
instead:
if ($customerCoupon = Mage::getModel('salesrule/rule_customer')->loadByCustomerRule($customerId, $coupon->getRuleId())) {
use
$customerCoupon = Mage::getModel('salesrule/rule_customer')->loadByCustomerRule($customerId, $coupon->getRuleId());
if ($customerCoupon->getId()) {
The text was updated successfully, but these errors were encountered:
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Reason:
In
Mage_SalesRule_Model_Observer:162
system is trying to decrease the code usage amount insalesrule_customer
but there's no entity to change. Used promo rule had no limitation per user, so Magento didn't create an entry after order placement.My solution:
It could check if the entity exists (
$object->getId()
) before trying to manipulate it.Mage_SalesRule_Model_Observer:162
instead:
use
The text was updated successfully, but these errors were encountered: