This issue is not related to WeltPixel extensions but a Magento 2 upgrade issue we've decided to document.
Everything works well when installing an extension on a clean Magento, but how about the upgrades? We need to keep up with the security updates, performance improvements and new features, so from time to time updating Magento is necessary and sometimes challenging as the new Magento releases are constantly changing and improving the core.
You can find one of the common issues we encountered when upgrading Magento 2.1.x to Magento 2.2 below.
Issue:
Module 'Magento_SalesRule':
Upgrading data.. SQLSTATE[23000]: Integrity constraint violation:
1062 Duplicate entry'0-0-0-0' for key 'PRIMARY', query was:
INSERT INTO `salesrule_product_attribute` () VALUES ()
Solution1:
Go to the location below and add the empty data condition to the Rule.php file.
vendor/magento/module-sales-rule/Model/ResourceModel/Rule.php line 352$connection->insertMultiple($this->getTable('salesrule_product_attribute'), $data);
wrap it in
if (!empty($data)) {
$connection->insertMultiple($this->getTable('salesrule_product_attribute'), $data);
}
After adding the condition, run the command below via SSH in the root of you Magento installation: php bin/magento setup:upgrade
Solution2:
Run this Query in PhpMyAdmin and truncate the tables below.
Note:This will delete data related to sales rules and coupons. Make sure to backup the database and save the tables in case you need to reimport or rebuild the rules. If you don't have custom sales rules, proceed with the query below in PhpMyAdmin.
TRUNCATE TABLE salesrule
;
TRUNCATE TABLE salesrule_coupon
;
TRUNCATE TABLE salesrule_coupon_usage
;
TRUNCATE TABLE salesrule_customer
;
TRUNCATE TABLE salesrule_product_attribute
;
After truncating the tables, run the command below via SSH in the root of you Magento installation: php bin/magento setup:upgrade
Comments
0 comments
Please sign in to leave a comment.