Skip to content

Commit

Permalink
skip stores with mailchimp disabled #2041 for magento 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Nov 27, 2024
1 parent 86b6310 commit c71467e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Cron/GenerateStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,23 @@ public function execute()
$data = [];
foreach ($this->storeManager->getStores() as $storeId => $val)
{
$mailChimpStoreId = $this->helper->getConfigValue(Data::XML_MAILCHIMP_STORE, $storeId);
$storeStatistics = [];
// Get currents mailchimp totals (orders, products, customers)
$storeStatistics['mailchimp'] = $this->getMailchimpTotals($storeId);
$storeStatistics['magento'] = $this->getMagentoTotals($storeId);
$data['statistics']['store'][$storeId] = $storeStatistics;
$data['batches'] = $this->getBatches($storeId, $mailChimpStoreId);
$data['jobs'] = $this->getJobs();
if ($this->helper->isMailChimpEnabled($storeId)) {
$mailChimpStoreId = $this->helper->getConfigValue(Data::XML_MAILCHIMP_STORE, $storeId);
$storeStatistics = [];
// Get currents mailchimp totals (orders, products, customers)
$storeStatistics['mailchimp'] = $this->getMailchimpTotals($storeId);
$storeStatistics['magento'] = $this->getMagentoTotals($storeId);
$data['statistics']['store'][$storeId] = $storeStatistics;
$data['batches'] = $this->getBatches($storeId, $mailChimpStoreId);
$data['jobs'] = $this->getJobs();
}
}
if (!empty($data)) {
$mailchimpNotification = $this->mailchimpNotificationFactory->create();
$mailchimpNotification->setNotificationData(json_encode($data));
$mailchimpNotification->setProcessed(false);
$mailchimpNotification->getResource()->save($mailchimpNotification);
}
$mailchimpNotification = $this->mailchimpNotificationFactory->create();
$mailchimpNotification->setNotificationData(json_encode($data));
$mailchimpNotification->setProcessed(false);
$mailchimpNotification->getResource()->save($mailchimpNotification);
}
private function getMagentoTotals($storeId)
{
Expand Down

0 comments on commit c71467e

Please sign in to comment.