Skip to content
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

closes #1107 for magento 2.2 #1127

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions Cron/BatchesClean.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,51 @@ class BatchesClean
* @var \Ebizmarts\MailChimp\Model\MailChimpSyncBatches
*/
protected $mailChimpSyncBatches;
/**
* @var \Ebizmarts\MailChimp\Model\MailChimpErrors
*/
protected $mailChimpErrors;

/**
* BatchesClean constructor.
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Ebizmarts\MailChimp\Model\MailChimpSyncBatches $mailChimpSyncBatches
* @param \Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors
*/
public function __construct(
\Ebizmarts\MailChimp\Helper\Data $helper,
\Ebizmarts\MailChimp\Model\MailChimpSyncBatches $_mailChimpSyncBatches
)
{
\Ebizmarts\MailChimp\Model\MailChimpSyncBatches $mailChimpSyncBatches,
\Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors
) {
$this->helper = $helper;
$this->mailChimpSyncBatches = $_mailChimpSyncBatches;
$this->mailChimpSyncBatches = $mailChimpSyncBatches;
$this->mailChimpErrors = $chimpErrors;
}
public function execute()
{

try {
$connection = $this->mailChimpErrors->getResource()->getConnection();
$tableName = $this->mailChimpErrors->getResource()->getMainTable();
$tableNameBatches = $this->mailChimpSyncBatches->getResource()->getMainTable();
$quoteInto = $connection->quoteInto(
"batch_id IN (SELECT batch_id FROM $tableNameBatches WHERE status IN('completed','canceled') AND ( date_add(modified_date, interval ? month) < now() OR modified_date IS NULL)) OR batch_id NOT IN(SELECT batch_id FROM $tableNameBatches)",
1
);
$connection->delete($tableName, $quoteInto);
} catch (\Exception $e) {
$this->helper->log($e->getMessage());
}
try {
$connection = $this->mailChimpSyncBatches->getResource()->getConnection();
$tableName = $this->mailChimpSyncBatches->getResource()->getMainTable();
$quoteInto = $connection->quoteInto('status IN("completed","canceled") and ( date_add(modified_date, interval ? month) < now() OR modified_date IS NULL)',1);
$quoteInto = $connection->quoteInto(
'status IN("completed","canceled") and ( date_add(modified_date, interval ? month) < now() OR modified_date IS NULL)',
1
);
$connection->delete($tableName, $quoteInto);
} catch( \Exception $e) {
} catch (\Exception $e) {
$this->helper->log($e->getMessage());
}
}
}
}