SpotlerSoftware / magento2-mailplus-connector

The MailPlus connector for magento 2
4 stars 19 forks source link

Incompatibility with native "sales_clean_quotes" cron job #3

Closed vpodorozh closed 6 years ago

vpodorozh commented 7 years ago

Hello,

I've got this error while execution of native Magento 2 "sales_clean_quotes" cron job on [Magento 2.1.7]:

SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`project_db`.`mp_quote_conversion`, CONSTRAINT `conversion_quote` FOREIGN KEY (`quote_id`) REFERENCES `quote` (`entity_id`) ON DELETE NO ACTION), query was: DELETE FROM `quote` WHERE (entity_id='2500')

Cron job "sales_clean_quotes" details:

<job name="sales_clean_quotes" instance="Magento\Sales\Cron\CleanExpiredQuotes" method="execute">
    <schedule>0 0 * * *</schedule>
</job>

Current job collects all inactive quotes that are older than the configured lifetime - and delete them. But after installation of MailPlus extension, Magento can't delete expired quotes due to the constraint that was built in \MailPlus\MailPlus\Setup\UpgradeSchema::upgrade .

As I can see from MailPlus extension logic, there is a need to disable quotes clean-up cron job "sales_clean_quotes", because MailPlus extension requires to have all quotes available in DB to provide full information about conversion.

Please check this issue, as tmp solution I will disable "sales_clean_quotes" cron job on mine project. Thank you.

PaulBoss commented 6 years ago

It seems when creating a foreign key via the DDL, Magento 2 defaults to "on delete no action" which is an error in this case. We need the data only once and our platform know which conversions etc. have been sent to MailPlus. It should have been an "on delete cascase". We will fix this in the next release.

vpodorozh commented 6 years ago

Any update?

PaulBoss commented 6 years ago

Fixed in v1.4.1