From a77a2e2c623e0b1168677701f4622a18adf42779 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Thu, 28 Nov 2024 12:49:29 -0300 Subject: [PATCH] add the time zone #2041 for magento 2.4 --- Cron/GenerateStatistics.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Cron/GenerateStatistics.php b/Cron/GenerateStatistics.php index 90bde892..f0797ace 100644 --- a/Cron/GenerateStatistics.php +++ b/Cron/GenerateStatistics.php @@ -2,8 +2,8 @@ namespace Ebizmarts\MailChimp\Cron; -use Magento\Framework\Component\ComponentRegistrar; use Magento\Store\Model\StoreManager; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory; @@ -56,6 +56,7 @@ class GenerateStatistics * @var ModuleVersion */ protected $moduleVersion; + protected $locale; protected $deleteAction = [ 0 => 'Unsubscribe', 1 => 'Delete', @@ -70,7 +71,8 @@ public function __construct( MailchimpSyncBatchesCollectionFactory $mailchimpSyncBatchesCollectionFactory, ScheduleCollectionFactory $scheduleCollectionFactory, ProductMetadataInterface $productMetadata, - ModuleVersion $moduleVersion + ModuleVersion $moduleVersion, + TimezoneInterface $locale ) { $this->mailchimpNotificationFactory = $mailchimpNotificationFactory; @@ -83,6 +85,7 @@ public function __construct( $this->scheduleCollectionFactory = $scheduleCollectionFactory; $this->productMetadata = $productMetadata; $this->moduleVersion = $moduleVersion; + $this->locale = $locale; } public function execute() { @@ -173,7 +176,7 @@ private function getMagentoTotals($storeId) } catch (\Exception $e) { $this->helper->log($e->getMessage()); } - + $options['time_zone'] = $this->locale->getConfigTimezone(\Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); return $options; } private function getMailchimpTotals($storeId)