From 19a906119493ca1887c8ab491718baefc0a9a056 Mon Sep 17 00:00:00 2001 From: gonzalo Date: Mon, 19 Jun 2023 16:27:53 -0300 Subject: [PATCH] create specific helper for ecommerce table #1708 for magento 2.4 --- .../Adminhtml/Ecommerce/ResetLocalErrors.php | 15 +- .../Ecommerce/ResetLocalErrorsNoRetry.php | 15 +- Controller/Cart/Loadquote.php | 15 +- Controller/Checkout/Success.php | 16 +- Helper/Data.php | 106 +------------ Helper/Sync.php | 146 ++++++++++++++++++ Model/Api/Cart.php | 19 +-- Model/Api/Customer.php | 13 +- Model/Api/Order.php | 13 +- Model/Api/Product.php | 16 +- Model/Api/PromoCodes.php | 17 +- Model/Api/PromoRules.php | 22 ++- Model/Api/Result.php | 16 +- Model/Api/Subscriber.php | 12 +- Model/Config/Backend/MonkeyStore.php | 14 +- Model/Plugin/Coupon.php | 16 +- Model/Plugin/Creditmemo.php | 13 +- Model/Plugin/Invoice.php | 13 +- Model/Plugin/Newsletter/Save.php | 14 +- Model/Plugin/Quote.php | 16 +- Model/Plugin/Ship.php | 13 +- Observer/Adminhtml/Product/DeleteAfter.php | 12 +- Observer/Customer/SaveBefore.php | 12 +- Observer/Sales/Order/SaveAfter.php | 16 +- Observer/SalesRule/Rule/DeleteAfter.php | 15 +- Ui/Component/Listing/Column/Customers.php | 14 +- Ui/Component/Listing/Column/Monkey.php | 131 ++++++++-------- Ui/Component/Listing/Column/Products.php | 15 +- 28 files changed, 483 insertions(+), 272 deletions(-) create mode 100644 Helper/Sync.php diff --git a/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php b/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php index 25a5e806..2f3c648b 100644 --- a/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php +++ b/Controller/Adminhtml/Ecommerce/ResetLocalErrors.php @@ -16,6 +16,7 @@ use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\Exception\ValidatorException; use Symfony\Component\Config\Definition\Exception\Exception; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class ResetLocalErrors extends \Magento\Backend\App\Action { @@ -27,29 +28,35 @@ class ResetLocalErrors extends \Magento\Backend\App\Action * @var \Ebizmarts\MailChimp\Helper\Data */ protected $helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $storeManager; /** - * ResetLocalErrors constructor. * @param \Magento\Backend\App\Action\Context $context * @param JsonFactory $resultJsonFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( \Magento\Backend\App\Action\Context $context, JsonFactory $resultJsonFactory, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface, - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { - + parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; $this->helper = $helper; $this->storeManager = $storeManagerInterface; + $this->syncHelper = $syncHelper; } public function execute() @@ -78,7 +85,7 @@ public function execute() $resultJson = $this->resultJsonFactory->create(); try { - $this->helper->resetErrors($mailchimpStore, true); + $this->syncHelper->resetErrors($mailchimpStore, true); } catch (ValidatorException $e) { $valid = 0; $message = $e->getMessage(); diff --git a/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php b/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php index 5f2d574b..69e7fa18 100644 --- a/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php +++ b/Controller/Adminhtml/Ecommerce/ResetLocalErrorsNoRetry.php @@ -16,6 +16,7 @@ use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\Exception\ValidatorException; use Symfony\Component\Config\Definition\Exception\Exception; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class ResetLocalErrorsNoRetry extends \Magento\Backend\App\Action { @@ -27,29 +28,35 @@ class ResetLocalErrorsNoRetry extends \Magento\Backend\App\Action * @var \Ebizmarts\MailChimp\Helper\Data */ protected $helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $storeManager; /** - * ResetLocalErrors constructor. * @param \Magento\Backend\App\Action\Context $context * @param JsonFactory $resultJsonFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManagerInterface * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( \Magento\Backend\App\Action\Context $context, JsonFactory $resultJsonFactory, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface, - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { - + parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; $this->helper = $helper; $this->storeManager = $storeManagerInterface; + $this->syncHelper = $syncHelper; } public function execute() @@ -78,7 +85,7 @@ public function execute() $resultJson = $this->resultJsonFactory->create(); try { - $this->helper->resetErrors($mailchimpStore, false); + $this->syncHelper->resetErrors($mailchimpStore, false); } catch (ValidatorException $e) { $valid = 0; $message = $e->getMessage(); diff --git a/Controller/Cart/Loadquote.php b/Controller/Cart/Loadquote.php index b1a73598..a6507bd1 100644 --- a/Controller/Cart/Loadquote.php +++ b/Controller/Cart/Loadquote.php @@ -5,13 +5,14 @@ * @copyright Copyright © 2017 Ebizmarts Corp.. All rights reserved. * @author info@ebizmarts.com */ - + namespace Ebizmarts\MailChimp\Controller\Cart; use Magento\Framework\App\Action\Action; use Magento\Framework\Controller\ResultFactory; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\App\Action\Context; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Loadquote extends Action { @@ -31,6 +32,10 @@ class Loadquote extends Action * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Framework\Url */ @@ -49,13 +54,13 @@ class Loadquote extends Action protected $_checkoutSession; /** - * Loadquote constructor. * @param Context $context * @param PageFactory $pageFactory * @param \Magento\Quote\Model\QuoteFactory $quote * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Framework\Url $urlHelper * @param \Magento\Customer\Model\Url $customerUrl */ @@ -66,14 +71,16 @@ public function __construct( \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Framework\Url $urlHelper, \Magento\Customer\Model\Url $customerUrl ) { - + $this->pageFactory = $pageFactory; $this->_quote = $quote; $this->_customerSession = $customerSession; $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_urlHelper = $urlHelper; $this->_message = $context->getMessageManager(); $this->_customerUrl = $customerUrl; @@ -99,7 +106,7 @@ public function execute() \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $magentoStoreId ); - $syncCommerce = $this->_helper->getChimpSyncEcommerce( + $syncCommerce = $this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $params['id'], \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE diff --git a/Controller/Checkout/Success.php b/Controller/Checkout/Success.php index 9199b957..2062b59a 100644 --- a/Controller/Checkout/Success.php +++ b/Controller/Checkout/Success.php @@ -13,6 +13,8 @@ namespace Ebizmarts\MailChimp\Controller\Checkout; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Success extends \Magento\Framework\App\Action\Action { /** @@ -35,15 +37,19 @@ class Success extends \Magento\Framework\App\Action\Action * @var \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory */ protected $_interestGroupFactory; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Success constructor. * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\View\Result\PageFactory $pageFactory * @param \Ebizmarts\MailChimp\Helper\Data $helper * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory * @param \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory + * @param SyncHelper $syncHelper */ public function __construct( \Magento\Framework\App\Action\Context $context, @@ -51,14 +57,16 @@ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, - \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory + \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory, + SyncHelper $syncHelper ) { - + $this->_pageFactory =$pageFactory; $this->_helper = $helper; $this->_checkoutSession = $checkoutSession; $this->_subscriberFactory = $subscriberFactory; $this->_interestGroupFactory= $interestGroupFactory; + $this->syncHelper = $syncHelper; parent::__construct($context); } @@ -112,7 +120,7 @@ protected function _updateSubscriber( $sync_error = null, $sync_modified = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $listId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER, diff --git a/Helper/Data.php b/Helper/Data.php index 0adaf57d..e72bd3cf 100755 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -84,7 +84,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper const SYNCERROR = 4; const NOTSYNCED = 5; - const NEVERSYNC = 6; + const NEVERSYNC = 0; const BATCH_CANCELED = 'canceled'; const BATCH_COMPLETED = 'completed'; @@ -135,18 +135,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper * @var \Magento\Customer\Model\ResourceModel\Customer\CustomerRepository */ private $_customer; - /** - * @var \Ebizmarts\MailChimp\Model\MailChimpErrors - */ - private $_mailChimpErrors; - /** - * @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory - */ - private $_mailChimpSyncEcommerce; - /** - * @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce - */ - private $_mailChimpSyncE; /** * @var \Ebizmarts\MailChimp\Model\MailChimpSyncBatches */ @@ -268,9 +256,6 @@ public function __construct( \Mailchimp $api, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Customer\Model\ResourceModel\CustomerRepository $customer, - \Ebizmarts\MailChimp\Model\MailChimpErrors $mailChimpErrors, - \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $mailChimpSyncEcommerce, - \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $mailChimpSyncE, \Ebizmarts\MailChimp\Model\MailChimpSyncBatches $syncBatches, \Ebizmarts\MailChimp\Model\MailChimpStoresFactory $mailChimpStoresFactory, \Ebizmarts\MailChimp\Model\MailChimpStores $mailChimpStores, @@ -300,9 +285,6 @@ public function __construct( $this->_config = $config; $this->_api = $api; $this->_customer = $customer; - $this->_mailChimpErrors = $mailChimpErrors; - $this->_mailChimpSyncEcommerce = $mailChimpSyncEcommerce; - $this->_mailChimpSyncE = $mailChimpSyncE; $this->_syncBatches = $syncBatches; $this->_mailChimpStores = $mailChimpStores; $this->_mailChimpStoresFactory = $mailChimpStoresFactory; @@ -840,93 +822,7 @@ public function getDateMicrotime() $date = date('Y-m-d-H-i-s') . '-' . $msecArray[1]; return $date; } - public function resetErrors($mailchimpStore, $retry) - { - try { - // clean the errors table - $connection = $this->_mailChimpErrors->getResource()->getConnection(); - $tableName = $this->_mailChimpErrors->getResource()->getMainTable(); - $connection->delete($tableName, "mailchimp_store_id = '".$mailchimpStore."'"); - // clean the syncecommerce table with errors - if ($retry) { - $connection = $this->_mailChimpSyncE->getResource()->getConnection(); - $tableName = $this->_mailChimpSyncE->getResource()->getMainTable(); - $connection->delete( - $tableName, - "mailchimp_store_id = '" . $mailchimpStore . "' and mailchimp_sync_error is not null" - ); - } - } catch (\Zend_Db_Exception $e) { - throw new ValidatorException(__($e->getMessage())); - } - } - public function resetEcommerce() - { - $this->resetErrors(); - } - public function saveEcommerceData( - $storeId, - $entityId, - $type, - $date = null, - $error = null, - $modified = null, - $deleted = null, - $token = null, - $sent = null - ) { - if (!empty($entityId)) { - $chimpSyncEcommerce = $this->getChimpSyncEcommerce($storeId, $entityId, $type); - if ($chimpSyncEcommerce->getRelatedId() == $entityId || - !$chimpSyncEcommerce->getRelatedId() && $modified != 1) { - $chimpSyncEcommerce->setMailchimpStoreId($storeId); - $chimpSyncEcommerce->setType($type); - $chimpSyncEcommerce->setRelatedId($entityId); - if ($modified!==null) { - $chimpSyncEcommerce->setMailchimpSyncModified($modified); - } else { - $chimpSyncEcommerce->setMailchimpSyncModified(0); - } - if ($date) { - $chimpSyncEcommerce->setMailchimpSyncDelta($date); - } elseif ($modified != 1) { - $chimpSyncEcommerce->setBatchId(null); - } - if ($error) { - $chimpSyncEcommerce->setMailchimpSyncError($error); - } - if ($deleted) { - $chimpSyncEcommerce->setMailchimpSyncDeleted($deleted); - $chimpSyncEcommerce->setMailchimpSyncModified(0); - } - if ($token) { - $chimpSyncEcommerce->setMailchimpToken($token); - } - if ($sent) { - $chimpSyncEcommerce->setMailchimpSent($sent); - } - $chimpSyncEcommerce->getResource()->save($chimpSyncEcommerce); - } - } - } - public function markEcommerceAsDeleted($relatedId, $type, $relatedDeletedId = null) - { - $this->_mailChimpSyncE->markAllAsDeleted($relatedId, $type, $relatedDeletedId); - } - public function ecommerceDeleteAllByIdType($id, $type, $mailchimpStoreId) - { - $this->_mailChimpSyncE->deleteAllByIdType($id, $type, $mailchimpStoreId); - } - public function deleteAllByBatchId($batchId) - { - $this->_mailChimpSyncE->deleteAllByBatchid($batchId); - } - public function getChimpSyncEcommerce($storeId, $id, $type) - { - $chimp = $this->_mailChimpSyncEcommerce->create(); - return $chimp->getByStoreIdType($storeId, $id, $type); - } public function loadStores() { diff --git a/Helper/Sync.php b/Helper/Sync.php new file mode 100644 index 00000000..5eabc9a1 --- /dev/null +++ b/Helper/Sync.php @@ -0,0 +1,146 @@ +chimpSyncEcommerceFactory = $chimpSyncEcommerceFactory; + $this->mailChimpErrors = $mailChimpErrors; + $this->chimpSyncEcommerce = $chimpSyncEcommerce; + $this->orderFactory = $orderFactory; + parent::__construct($context); + } + public function saveEcommerceData( + $storeId, + $entityId, + $type, + $date = null, + $error = null, + $modified = null, + $deleted = null, + $token = null, + $sent = null + ) { + if (!empty($entityId)) { + $chimpSyncEcommerce = $this->getChimpSyncEcommerce($storeId, $entityId, $type); + if ($chimpSyncEcommerce->getRelatedId() == $entityId || + !$chimpSyncEcommerce->getRelatedId() && $modified != 1) { + $chimpSyncEcommerce->setMailchimpStoreId($storeId); + $chimpSyncEcommerce->setType($type); + $chimpSyncEcommerce->setRelatedId($entityId); + if ($modified!==null) { + $chimpSyncEcommerce->setMailchimpSyncModified($modified); + } else { + $chimpSyncEcommerce->setMailchimpSyncModified(0); + } + if ($date) { + $chimpSyncEcommerce->setMailchimpSyncDelta($date); + } elseif ($modified != 1) { + $chimpSyncEcommerce->setBatchId(null); + } + if ($error) { + $chimpSyncEcommerce->setMailchimpSyncError($error); + } + if ($deleted) { + $chimpSyncEcommerce->setMailchimpSyncDeleted($deleted); + $chimpSyncEcommerce->setMailchimpSyncModified(0); + } + if ($token) { + $chimpSyncEcommerce->setMailchimpToken($token); + } + if ($sent) { + $chimpSyncEcommerce->setMailchimpSent($sent); + } + $chimpSyncEcommerce->getResource()->save($chimpSyncEcommerce); + } + } + if ($type==\Ebizmarts\MailChimp\Helper\Data::IS_ORDER) { + if ($sent||$error) { + $order = $this->orderFactory->create()->loadByAttribute('entity_id', $entityId); + if ($sent) { + $order->setMailchimpSent($sent); + } + if ($error) { + $order->setMailchimpSyncError($error); + } + $order->save(); + } + } + } + public function getChimpSyncEcommerce($storeId, $id, $type) + { + $chimp = $this->chimpSyncEcommerceFactory->create(); + return $chimp->getByStoreIdType($storeId, $id, $type); + } + public function markEcommerceAsDeleted($relatedId, $type, $relatedDeletedId = null) + { + $this->chimpSyncEcommerce->markAllAsDeleted($relatedId, $type, $relatedDeletedId); + } + public function ecommerceDeleteAllByIdType($id, $type, $mailchimpStoreId) + { + $this->chimpSyncEcommerce->deleteAllByIdType($id, $type, $mailchimpStoreId); + } + public function deleteAllByBatchId($batchId) + { + $this->chimpSyncEcommerce->deleteAllByBatchid($batchId); + } + public function resetErrors($mailchimpStore, $retry) + { + try { + // clean the errors table + $connection = $this->mailChimpErrors->getResource()->getConnection(); + $tableName = $this->mailChimpErrors->getResource()->getMainTable(); + $connection->delete($tableName, "mailchimp_store_id = '".$mailchimpStore."'"); + // clean the syncecommerce table with errors + if ($retry) { + $connection = $this->chimpSyncEcommerce->getResource()->getConnection(); + $tableName = $this->chimpSyncEcommerce->getResource()->getMainTable(); + $connection->delete( + $tableName, + "mailchimp_store_id = '" . $mailchimpStore . "' and mailchimp_sync_error is not null" + ); + } + } catch (\Zend_Db_Exception $e) { + throw new ValidatorException(__($e->getMessage())); + } + } +} diff --git a/Model/Api/Cart.php b/Model/Api/Cart.php index 79b564b3..eabe664c 100644 --- a/Model/Api/Cart.php +++ b/Model/Api/Cart.php @@ -13,6 +13,7 @@ namespace Ebizmarts\MailChimp\Model\Api; use Symfony\Component\Config\Definition\Exception\Exception; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Cart { @@ -57,10 +58,14 @@ class Cart * @var \Magento\Framework\Url */ protected $_urlHelper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Cart constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteColletcion * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param Product $apiProduct @@ -71,6 +76,7 @@ class Cart */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $quoteColletcion, \Magento\Customer\Model\CustomerFactory $customerFactory, \Ebizmarts\MailChimp\Model\Api\Product $apiProduct, @@ -79,7 +85,7 @@ public function __construct( \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, \Magento\Framework\Url $urlHelper ) { - + $this->_helper = $helper; $this->_quoteCollection = $quoteColletcion; $this->_customerFactory = $customerFactory; @@ -88,6 +94,7 @@ public function __construct( $this->_orderCollectionFactory = $orderCollectionFactory; $this->_countryFactory = $countryFactory; $this->_urlHelper = $urlHelper; + $this->syncHelper = $syncHelper; } /** @@ -643,12 +650,6 @@ protected function _getCustomer(\Magento\Quote\Model\Quote $cart, $mailchimpStor $customer['address'] = $address; } } - - //company -// if ($billingAddress->getCompany()) { -// $customer["company"] = $billingAddress->getCompany(); -// } - return $customer; } @@ -684,7 +685,7 @@ protected function _updateQuote( $sync_modified = null, $sync_deleted = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE, diff --git a/Model/Api/Customer.php b/Model/Api/Customer.php index 46160cc8..23437e97 100644 --- a/Model/Api/Customer.php +++ b/Model/Api/Customer.php @@ -16,6 +16,7 @@ use Magento\Directory\Model\CountryFactory; use Magento\Framework\Exception\State\ExpiredException; use Symfony\Component\Config\Definition\Exception\Exception; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Customer { @@ -53,10 +54,14 @@ class Customer * @var string */ protected $_batchId; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Customer constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $collection * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollection @@ -66,6 +71,7 @@ class Customer */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory $collection, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollection, @@ -73,7 +79,7 @@ public function __construct( \Magento\Customer\Model\Address $address, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory ) { - + $this->_helper = $helper; $this->_collection = $collection; $this->_orderCollection = $orderCollection; @@ -83,6 +89,7 @@ public function __construct( $this->_customerFactory = $customerFactory; $this->_countryFactory = $countryFactory; $this->subscriberFactory = $subscriberFactory; + $this->syncHelper = $syncHelper; } public function sendCustomers($storeId) { @@ -273,7 +280,7 @@ protected function _updateCustomer( $sync_error = null, $sync_modified = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER, diff --git a/Model/Api/Order.php b/Model/Api/Order.php index bca463bc..380c1476 100644 --- a/Model/Api/Order.php +++ b/Model/Api/Order.php @@ -14,6 +14,7 @@ namespace Ebizmarts\MailChimp\Model\Api; use Magento\SalesRule\Model\RuleRepository; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; use Symfony\Component\Config\Definition\Exception\Exception; class Order @@ -75,6 +76,10 @@ class Order * @var \Magento\Framework\Url */ protected $_urlHelper; + /** + * @var SyncHelper + */ + private $syncHelper; protected $_chimpSyncEcommerce; protected $_firstDate; protected $_counter; @@ -82,8 +87,8 @@ class Order protected $_batchId; /** - * Order constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Sales\Model\OrderRepository $order * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory * @param \Magento\Catalog\Model\ResourceModel\Product $product @@ -98,6 +103,7 @@ class Order */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Sales\Model\OrderRepository $order, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, \Magento\Catalog\Model\ResourceModel\Product $product, @@ -112,6 +118,7 @@ public function __construct( ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_order = $order; $this->_orderCollectionFactory = $orderCollectionFactory; $this->_apiProduct = $apiProduct; @@ -406,7 +413,7 @@ protected function generatePOSTPayload( foreach ($items as $item) { $variant = null; try { - $productSyncData = $this->_helper->getChimpSyncEcommerce( + $productSyncData = $this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $item->getProductId(), \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT @@ -735,7 +742,7 @@ protected function _updateOrder($storeId, $entityId, $sync_delta = null, $sync_e } else { $sent = \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC; } - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, diff --git a/Model/Api/Product.php b/Model/Api/Product.php index 5b80982c..41cf1781 100644 --- a/Model/Api/Product.php +++ b/Model/Api/Product.php @@ -12,6 +12,8 @@ namespace Ebizmarts\MailChimp\Model\Api; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Product { const DOWNLOADABLE = 'downloadable'; @@ -69,13 +71,17 @@ class Product * @var \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory */ protected $_categoryCollection; + /** + * @var SyncHelper + */ + private $syncHelper; protected $includingTaxes; /** - * Product constructor. * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollection * @param \Magento\Catalog\Model\ProductRepository $productRepository * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param \Magento\Catalog\Model\CategoryRepository $categoryRepository @@ -89,6 +95,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollection, \Magento\Catalog\Model\ProductRepository $productRepository, \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Catalog\Helper\Image $imageHelper, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\Catalog\Model\CategoryRepository $categoryRepository, @@ -101,6 +108,7 @@ public function __construct( $this->_productRepository = $productRepository; $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_productCollection = $productCollection; $this->_imageHelper = $imageHelper; $this->_stockRegistry = $stockRegistry; @@ -206,7 +214,7 @@ protected function _markSpecialPrices($magentoStoreId, $mailchimpStoreId) ); foreach ($collection as $item) { $productId = $this->_productRepository->get($item->getSku(),false, $magentoStoreId)->getId(); - $mailchimpSync = $this->_helper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO'); + $mailchimpSync = $this->syncHelper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO'); if ($mailchimpSync->getMailchimpSyncDelta() < $item->getSpecialFromDate()) { $this->_updateProduct($mailchimpStoreId, $productId, null, null, 1); } @@ -229,7 +237,7 @@ protected function _markSpecialPrices($magentoStoreId, $mailchimpStoreId) ); foreach ($collection2 as $item) { $productId = $this->_productRepository->get($item->getSku(),false, $magentoStoreId)->getId(); - $mailchimpSync = $this->_helper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO'); + $mailchimpSync = $this->syncHelper->getChimpSyncEcommerce($mailchimpStoreId, $productId, 'PRO'); if ($mailchimpSync->getMailchimpSyncDelta() < $item->getSpecialToDate()) { $this->_updateProduct($mailchimpStoreId, $productId, null, null, 1); } @@ -654,7 +662,7 @@ protected function _updateProduct( $sync_error = null, $sync_modified = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT, diff --git a/Model/Api/PromoCodes.php b/Model/Api/PromoCodes.php index 2c7181f6..ab142452 100644 --- a/Model/Api/PromoCodes.php +++ b/Model/Api/PromoCodes.php @@ -13,6 +13,7 @@ namespace Ebizmarts\MailChimp\Model\Api; use Magento\TestFramework\Inspection\Exception; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class PromoCodes { @@ -43,10 +44,14 @@ class PromoCodes * @var \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory */ private $_syncCollection; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * PromoCodes constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\SalesRule\Model\ResourceModel\Coupon\CollectionFactory $couponCollection * @param \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $ruleCollection * @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $chimpSyncEcommerce @@ -55,14 +60,16 @@ class PromoCodes */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\SalesRule\Model\ResourceModel\Coupon\CollectionFactory $couponCollection, \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $ruleCollection, \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $chimpSyncEcommerce, \Ebizmarts\MailChimp\Model\Api\PromoRules $promoRules, \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $syncCollection ) { - + $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_couponCollection = $couponCollection; $this->_ruleCollection = $ruleCollection; $this->_chimpSyncEcommerce = $chimpSyncEcommerce; @@ -105,7 +112,7 @@ protected function _sendDeletedCoupons($mailchimpStoreId, $magentoStoreId) $batchArray[$counter]['path'] = "/ecommerce/stores/$mailchimpStoreId/promo-rules/$ruleId/promo-codes/$couponId"; $counter++; - $syncCoupon =$this->_helper->getChimpSyncEcommerce( + $syncCoupon =$this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $couponId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE @@ -152,7 +159,7 @@ protected function _sendNewCoupons($mailchimpStoreId, $magentoStoreId) $ruleId = $item->getRuleId(); $couponId = $item->getCouponId(); try { - $promoRule = $this->_helper->getChimpSyncEcommerce( + $promoRule = $this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE @@ -255,7 +262,7 @@ protected function _updateSyncData( $sync_modified = null, $sync_deleted = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE, diff --git a/Model/Api/PromoRules.php b/Model/Api/PromoRules.php index 7469007b..72ebf0e6 100644 --- a/Model/Api/PromoRules.php +++ b/Model/Api/PromoRules.php @@ -14,6 +14,8 @@ namespace Ebizmarts\MailChimp\Model\Api; use Magento\Cms\Test\Unit\Controller\Adminhtml\Page\MassEnableTest; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class PromoRules { @@ -48,10 +50,14 @@ class PromoRules * @var \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory */ protected $_syncCollection; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * PromoRules constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $collection * @param \Magento\SalesRule\Model\RuleRepository $ruleRepo * @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $chimpSyncEcommerce @@ -59,13 +65,15 @@ class PromoRules */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\SalesRule\Model\ResourceModel\Rule\CollectionFactory $collection, \Magento\SalesRule\Model\RuleRepository $ruleRepo, \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerceFactory $chimpSyncEcommerce, \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce\CollectionFactory $syncCollection ) { - + $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_collection = $collection; $this->_chimpSyncEcommerce = $chimpSyncEcommerce; $this->_ruleRepo = $ruleRepo; @@ -103,7 +111,7 @@ protected function _getDeletedPromoRules($mailchimpStoreId, $magentoStoreId) try { $mailchimpRule = $api->ecommerce->promoCodes->getAll($mailchimpStoreId, $ruleId); foreach ($mailchimpRule['promo_codes'] as $promoCode) { - $this->_helper->ecommerceDeleteAllByIdType( + $this->syncHelper->ecommerceDeleteAllByIdType( $promoCode['id'], \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE, $mailchimpStoreId @@ -116,7 +124,7 @@ protected function _getDeletedPromoRules($mailchimpStoreId, $magentoStoreId) } catch (\Mailchimp_Error $e) { $this->_helper->log($e->getFriendlyMessage()); } - $this->_helper->ecommerceDeleteAllByIdType( + $this->syncHelper->ecommerceDeleteAllByIdType( $ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE, $mailchimpStoreId @@ -152,7 +160,7 @@ protected function _getModifiedPromoRules($mailchimpStoreId, $magentoStoreId) try { $mailchimpRule = $api->ecommerce->promoCodes->getAll($mailchimpStoreId, $ruleId); foreach ($mailchimpRule['promo_codes'] as $promoCode) { - $this->_helper->ecommerceDeleteAllByIdType( + $this->syncHelper->ecommerceDeleteAllByIdType( $promoCode['id'], \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE, $mailchimpStoreId @@ -161,7 +169,7 @@ protected function _getModifiedPromoRules($mailchimpStoreId, $magentoStoreId) } catch (\Mailchimp_Error $e) { $this->_helper->log($e->getFriendlyMessage()); } - $this->_helper->ecommerceDeleteAllByIdType( + $this->syncHelper->ecommerceDeleteAllByIdType( $rule->getRuleId(), \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE, $mailchimpStoreId @@ -320,7 +328,7 @@ private function _getMailChimpTarget($action, $shipping) */ protected function _updateSyncData($storeId, $entityId, $sync_delta = null, $sync_error = '', $sync_modified = 0) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $storeId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE, diff --git a/Model/Api/Result.php b/Model/Api/Result.php index 68cdfea1..8790f5cf 100644 --- a/Model/Api/Result.php +++ b/Model/Api/Result.php @@ -13,6 +13,8 @@ namespace Ebizmarts\MailChimp\Model\Api; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Result { const MAILCHIMP_TEMP_DIR = 'Mailchimp'; @@ -24,6 +26,10 @@ class Result * @var \Ebizmarts\MailChimp\Helper\Data */ private $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Framework\Archive */ @@ -42,8 +48,8 @@ class Result private $_curlFactory; /** - * Result constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches\CollectionFactory $batchCollection * @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $chimpErrors * @param \Magento\Framework\Archive $archive @@ -52,15 +58,17 @@ class Result */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches\CollectionFactory $batchCollection, \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $chimpErrors, \Magento\Framework\Archive $archive, \Magento\Framework\Filesystem\Driver\File $driver, \Magento\Framework\HTTP\Client\CurlFactory $curlFactory ) { - + $this->_batchCollection = $batchCollection; $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_archive = $archive; $this->_chimpErrors = $chimpErrors; $this->_driver = $driver; @@ -88,7 +96,7 @@ public function processResponses($storeId, $isMailChimpStoreId = false, $mailchi } elseif ($files === false) { $item->setStatus(\Ebizmarts\MailChimp\Helper\Data::BATCH_ERROR); $item->getResource()->save($item); - $this->_helper->deleteAllByBatchId($item->getBatchId()); + $this->syncHelper->deleteAllByBatchId($item->getBatchId()); continue; } $baseDir = $this->_helper->getBaseDir(); @@ -294,7 +302,7 @@ private function _updateSyncData($mailchimpStoreId, $listId, $type, $id, $error, } else { $mailchimpStore = $mailchimpStoreId; } - $chimpSync = $this->_helper->getChimpSyncEcommerce($mailchimpStore, $id, $type); + $chimpSync = $this->syncHelper->getChimpSyncEcommerce($mailchimpStore, $id, $type); if ($chimpSync->getMailchimpStoreId() == $mailchimpStore && $chimpSync->getType() == $type && $chimpSync->getRelatedId() == $id) { $chimpSync->setMailchimpSent($status); diff --git a/Model/Api/Subscriber.php b/Model/Api/Subscriber.php index 9cc1d5b5..530335fd 100644 --- a/Model/Api/Subscriber.php +++ b/Model/Api/Subscriber.php @@ -12,6 +12,8 @@ */ namespace Ebizmarts\MailChimp\Model\Api; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Subscriber { const BATCH_LIMIT = 100; @@ -31,23 +33,29 @@ class Subscriber * @var \Magento\Newsletter\Model\SubscriberFactory */ protected $_subscriberFactory; + /** + * @var SyncHelper + */ + private $syncHelper; protected $_interest=null; /** - * Subscriber constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollection * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory * @param \Magento\Framework\Message\ManagerInterface $message */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollection, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Magento\Framework\Message\ManagerInterface $message ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_subscriberCollection = $subscriberCollection; $this->_message = $message; $this->_subscriberFactory = $subscriberFactory; @@ -204,7 +212,7 @@ protected function _updateSubscriber( $sync_error = null, $sync_modified = null ) { - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $listId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER, diff --git a/Model/Config/Backend/MonkeyStore.php b/Model/Config/Backend/MonkeyStore.php index 2a4a283a..0976f210 100644 --- a/Model/Config/Backend/MonkeyStore.php +++ b/Model/Config/Backend/MonkeyStore.php @@ -13,12 +13,18 @@ namespace Ebizmarts\MailChimp\Model\Config\Backend; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class MonkeyStore extends \Magento\Framework\App\Config\Value { /** * @var \Ebizmarts\MailChimp\Helper\Data */ private $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Config\Model\ResourceModel\Config */ @@ -36,16 +42,16 @@ class MonkeyStore extends \Magento\Framework\App\Config\Value const MAX_LISTS = 200; /** - * ApiKey constructor. * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param ScopeConfigInterface $config + * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Config\Model\ResourceModel\Config $resourceConfig * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Store\Model\StoreManager $storeManager * @param array $data */ @@ -59,10 +65,12 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Store\Model\StoreManager $storeManager, array $data = [] ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->resourceConfig = $resourceConfig; $this->_date = $date; $this->_storeManager = $storeManager; @@ -132,7 +140,7 @@ public function beforeSave() } if ($found==1) { $this->_helper->cancelAllPendingBatches($mailchimpStore); - $this->_helper->resetErrors($mailchimpStore, true); + $this->syncHelper->resetErrors($mailchimpStore, true); } $this->_helper->restoreAllCanceledBatches($this->getValue()); if ($createWebhook) { diff --git a/Model/Plugin/Coupon.php b/Model/Plugin/Coupon.php index 04fdb783..e53e9f0c 100644 --- a/Model/Plugin/Coupon.php +++ b/Model/Plugin/Coupon.php @@ -13,23 +13,27 @@ namespace Ebizmarts\MailChimp\Model\Plugin; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Coupon { - protected $_helper; + /** + * @var SyncHelper + */ + private $synHelper; /** - * Coupon constructor. - * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $synHelper */ public function __construct( - \Ebizmarts\MailChimp\Helper\Data $helper + SyncHelper $synHelper ) { - $this->_helper = $helper; + $this->synHelper = $synHelper; } public function afterAfterDelete(\Magento\SalesRule\Model\Coupon $coupon) { - $this->_helper->markEcommerceAsDeleted( + $this->synHelper->markEcommerceAsDeleted( $coupon->getCouponId(), \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE, $coupon->getRuleId() diff --git a/Model/Plugin/Creditmemo.php b/Model/Plugin/Creditmemo.php index 5cfe1ae7..48045b1c 100644 --- a/Model/Plugin/Creditmemo.php +++ b/Model/Plugin/Creditmemo.php @@ -13,6 +13,7 @@ use Magento\Sales\Api\Data\CreditmemoInterface; use Magento\Sales\Api\CreditmemoRepositoryInterface as SalesCreditmemoRepositoryInterface; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Creditmemo { @@ -20,15 +21,21 @@ class Creditmemo * @var \Ebizmarts\MailChimp\Helper\Data */ private $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Ship constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function afterSave( SalesCreditmemoRepositoryInterface $subject, @@ -38,7 +45,7 @@ public function afterSave( \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $creditmemo->getStoreId() ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $creditmemo->getOrderId(), \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, diff --git a/Model/Plugin/Invoice.php b/Model/Plugin/Invoice.php index 471980d3..254211b1 100644 --- a/Model/Plugin/Invoice.php +++ b/Model/Plugin/Invoice.php @@ -13,6 +13,7 @@ use Magento\Sales\Api\Data\InvoiceInterface; use Magento\Sales\Model\Order\Invoice as SalesInvoice; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Invoice { @@ -20,15 +21,21 @@ class Invoice * @var \Ebizmarts\MailChimp\Helper\Data */ private $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Ship constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function afterSave( SalesInvoice $subject, @@ -38,7 +45,7 @@ public function afterSave( \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $invoice->getStoreId() ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $invoice->getOrderId(), \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, diff --git a/Model/Plugin/Newsletter/Save.php b/Model/Plugin/Newsletter/Save.php index 0ee2a32c..0107ac1b 100644 --- a/Model/Plugin/Newsletter/Save.php +++ b/Model/Plugin/Newsletter/Save.php @@ -13,12 +13,18 @@ namespace Ebizmarts\MailChimp\Model\Plugin\Newsletter; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Save { /** * @var \Ebizmarts\MailChimp\Helper\Data */ protected $helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Customer\Model\Session */ @@ -37,8 +43,8 @@ class Save protected $interestGroupFactory; /** - * Save constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory * @param \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory @@ -46,13 +52,15 @@ class Save */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Customer\Model\Session $customerSession, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Ebizmarts\MailChimp\Model\MailChimpInterestGroupFactory $interestGroupFactory, \Magento\Framework\App\Request\Http $request ) { - + $this->helper = $helper; + $this->syncHelper = $syncHelper; $this->customerSession = $customerSession; $this->subscriberFactory = $subscriberFactory; $this->request = $request; @@ -104,7 +112,7 @@ protected function _updateSubscriber( $sync_error = null, $sync_modified = null ) { - $this->helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $listId, $entityId, \Ebizmarts\MailChimp\Helper\Data::IS_SUBSCRIBER, diff --git a/Model/Plugin/Quote.php b/Model/Plugin/Quote.php index 27b4c3cb..76f9d062 100644 --- a/Model/Plugin/Quote.php +++ b/Model/Plugin/Quote.php @@ -12,6 +12,8 @@ */ namespace Ebizmarts\MailChimp\Model\Plugin; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Quote { /** @@ -22,19 +24,25 @@ class Quote * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Quote constructor. * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager, - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { - + $this->_cookieManager = $cookieManager; $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function beforeBeforeSave(\Magento\Quote\Model\Quote $quote) @@ -51,7 +59,7 @@ public function beforeBeforeSave(\Magento\Quote\Model\Quote $quote) \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $quote->getStoreId() ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $quote->getId(), \Ebizmarts\MailChimp\Helper\Data::IS_QUOTE, diff --git a/Model/Plugin/Ship.php b/Model/Plugin/Ship.php index 8568e031..26275f6f 100644 --- a/Model/Plugin/Ship.php +++ b/Model/Plugin/Ship.php @@ -13,6 +13,7 @@ use Magento\Sales\Api\Data\ShipmentInterface; use Magento\Sales\Model\Order\Shipment as SalesShipment; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Ship { @@ -20,15 +21,21 @@ class Ship * @var \Ebizmarts\MailChimp\Helper\Data */ private $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * Ship constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function afterSave( SalesShipment $subject, @@ -38,7 +45,7 @@ public function afterSave( \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $shipment->getStoreId() ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $shipment->getOrderId(), \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, diff --git a/Observer/Adminhtml/Product/DeleteAfter.php b/Observer/Adminhtml/Product/DeleteAfter.php index 83372d67..2c234dd6 100644 --- a/Observer/Adminhtml/Product/DeleteAfter.php +++ b/Observer/Adminhtml/Product/DeleteAfter.php @@ -6,6 +6,8 @@ use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class DeleteAfter implements ObserverInterface @@ -14,6 +16,10 @@ class DeleteAfter implements ObserverInterface * @var \Ebizmarts\MailChimp\Helper\Data */ protected $helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var Configurable */ @@ -21,14 +27,17 @@ class DeleteAfter implements ObserverInterface /** * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param Configurable $configurable */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, Configurable $configurable ) { $this->helper = $helper; + $this->syncHelper = $syncHelper; $this->configurable = $configurable; } function execute(Observer $observer) @@ -52,7 +61,6 @@ function execute(Observer $observer) } protected function _updateProduct($entityId) { - $this->helper->markEcommerceAsDeleted($entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT); + $this->syncHelper->markEcommerceAsDeleted($entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT); } - } diff --git a/Observer/Customer/SaveBefore.php b/Observer/Customer/SaveBefore.php index 1e7b39da..8d727ec6 100644 --- a/Observer/Customer/SaveBefore.php +++ b/Observer/Customer/SaveBefore.php @@ -13,6 +13,8 @@ namespace Ebizmarts\MailChimp\Observer\Customer; use Magento\Framework\Event\Observer; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class SaveBefore implements \Magento\Framework\Event\ObserverInterface { @@ -20,22 +22,28 @@ class SaveBefore implements \Magento\Framework\Event\ObserverInterface * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Newsletter\Model\SubscriberFactory */ protected $subscriberFactory; /** - * SaveBefore constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ public function __construct( \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory ) { $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->subscriberFactory = $subscriberFactory; } @@ -52,7 +60,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $storeId ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $customer->getId(), \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER, diff --git a/Observer/Sales/Order/SaveAfter.php b/Observer/Sales/Order/SaveAfter.php index b0458961..fbfaec2d 100644 --- a/Observer/Sales/Order/SaveAfter.php +++ b/Observer/Sales/Order/SaveAfter.php @@ -14,6 +14,8 @@ namespace Ebizmarts\MailChimp\Observer\Sales\Order; use Magento\Framework\Event\Observer; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class SaveAfter implements \Magento\Framework\Event\ObserverInterface { @@ -21,16 +23,22 @@ class SaveAfter implements \Magento\Framework\Event\ObserverInterface * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** - * SaveAfter constructor. * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( - \Ebizmarts\MailChimp\Helper\Data $helper + \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper ) { - + $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function execute(\Magento\Framework\Event\Observer $observer) @@ -40,7 +48,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $order->getStoreId() ); - $this->_helper->saveEcommerceData( + $this->syncHelper->saveEcommerceData( $mailchimpStoreId, $order->getId(), \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, diff --git a/Observer/SalesRule/Rule/DeleteAfter.php b/Observer/SalesRule/Rule/DeleteAfter.php index 55623050..79135684 100644 --- a/Observer/SalesRule/Rule/DeleteAfter.php +++ b/Observer/SalesRule/Rule/DeleteAfter.php @@ -13,6 +13,8 @@ namespace Ebizmarts\MailChimp\Observer\SalesRule\Rule; use Magento\Framework\Event\Observer; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class DeleteAfter implements \Magento\Framework\Event\ObserverInterface { @@ -21,28 +23,27 @@ class DeleteAfter implements \Magento\Framework\Event\ObserverInterface */ protected $_ecommerce; /** - * @var \Ebizmarts\MailChimp\Helper\Data + * @var SyncHelper */ - protected $_helper; + protected $syncHelper; /** - * SaveAfter constructor. * @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce - * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper */ public function __construct( \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce, - \Ebizmarts\MailChimp\Helper\Data $helper + SyncHelper $syncHelper ) { $this->_ecommerce = $ecommerce; - $this->_helper = $helper; + $this->syncHelper = $syncHelper; } public function execute(\Magento\Framework\Event\Observer $observer) { $rule = $observer->getEvent()->getRule(); $ruleId = $rule->getRuleId(); - $this->_helper->markEcommerceAsDeleted($ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE); + $this->syncHelper->markEcommerceAsDeleted($ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE); } } diff --git a/Ui/Component/Listing/Column/Customers.php b/Ui/Component/Listing/Column/Customers.php index 572c172c..33cde55d 100644 --- a/Ui/Component/Listing/Column/Customers.php +++ b/Ui/Component/Listing/Column/Customers.php @@ -5,8 +5,9 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; -use \Magento\Ui\Component\Listing\Columns\Column; +use Magento\Ui\Component\Listing\Columns\Column; use Magento\Customer\Model\CustomerFactory; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; class Customers extends Column { @@ -26,6 +27,10 @@ class Customers extends Column * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory */ @@ -38,6 +43,7 @@ class Customers extends Column * @param \Magento\Framework\View\Asset\Repository $assetRepository * @param CustomerFactory $customerFactory * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory * @param array $components * @param array $data @@ -49,6 +55,7 @@ public function __construct( \Magento\Framework\View\Asset\Repository $assetRepository, CustomerFactory $customerFactory, \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory, array $components = [], array $data = []) @@ -57,6 +64,7 @@ public function __construct( $this->_assetRepository = $assetRepository; $this->_customerFactory = $customerFactory; $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_mailChimpErrorsFactory = $mailChimpErrorsFactory; parent::__construct($context, $uiComponentFactory, $components, $data); } @@ -79,7 +87,7 @@ public function prepareDataSource(array $dataSource) \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $customer->getStoreId() ); - $syncData = $this->_helper->getChimpSyncEcommerce( + $syncData = $this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $customer->getId(), \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER @@ -164,4 +172,4 @@ private function _getError($customerId, $storeId) return $error->getByStoreIdType($storeId, $customerId, \Ebizmarts\MailChimp\Helper\Data::IS_CUSTOMER); } -} \ No newline at end of file +} diff --git a/Ui/Component/Listing/Column/Monkey.php b/Ui/Component/Listing/Column/Monkey.php index a37b3865..ff1bd4eb 100644 --- a/Ui/Component/Listing/Column/Monkey.php +++ b/Ui/Component/Listing/Column/Monkey.php @@ -105,78 +105,73 @@ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { + $this->_helper->log($item); $status = $item['mailchimp_flag']; - $order = $this->_orderFactory->create()->loadByIncrementId($item['increment_id']); + $orderId = $item['increment_id']; + $sync = $item['mailchimp_sent']; + $error = $item['mailchimp_sync_error']; + + $order = $this->_orderFactory->create()->loadByIncrementId($orderId); $menu = false; $params = ['_secure' => $this->_requestInterfase->isSecure()]; - if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $order->getStoreId())) { - $mailchimpStoreId = $this->_helper->getConfigValue( - \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, - $order->getStoreId() - ); - $syncData = $this->_helper->getChimpSyncEcommerce( - $mailchimpStoreId, - $order->getId(), - \Ebizmarts\MailChimp\Helper\Data::IS_ORDER - ); + $storeId = $order->getStoreId(); + $this->_helper->log("Store [$storeId]"); + if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $storeId)) { $alt = ''; - if (!$syncData || $syncData->getMailchimpStoreId() != $mailchimpStoreId || - $syncData->getRelatedId() != $order->getId() || - $syncData->getType() != \Ebizmarts\MailChimp\Helper\Data::IS_ORDER) { - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/no.png', - $params - ); - $text = __('Syncing'); - } else { - $sync = $syncData->getMailchimpSent(); - switch ($sync) { - case \Ebizmarts\MailChimp\Helper\Data::SYNCED: - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/yes.png', - $params - ); - $text = __('Synced'); - $menu = true; - break; - case \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC: - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/waiting.png', - $params - ); - $text = __('Waiting'); - break; - case \Ebizmarts\MailChimp\Helper\Data::SYNCERROR: - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/error.png', - $params - ); - $text = __('Error'); - $orderError = $this->_getError($order->getId(), $order->getStoreId()); - if ($orderError) { - $alt = $orderError->getErrors(); - } - break; - case \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC: - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/resync.png', - $params - ); - $text = __('Resyncing'); - $menu = true; - break; - case \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED: - $url = $this->_assetRepository->getUrlWithParams( - 'Ebizmarts_MailChimp::images/never.png', - $params - ); - $text = __('With error'); - $alt = $syncData->getMailchimpSyncError(); - break; - default: - $url =''; - $text = ''; - } + $this->_helper->log("Order [$orderId] Status [$sync] Error [$error]"); + switch ($sync) { + case \Ebizmarts\MailChimp\Helper\Data::NEVERSYNC: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/no.png', + $params + ); + $text = __('Syncing'); + break; + case \Ebizmarts\MailChimp\Helper\Data::SYNCED: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/yes.png', + $params + ); + $text = __('Synced'); + $menu = true; + break; + case \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/waiting.png', + $params + ); + $text = __('Waiting'); + break; + case \Ebizmarts\MailChimp\Helper\Data::SYNCERROR: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/error.png', + $params + ); + $text = __('Error'); + $orderError = $this->_getError($orderId, $storeId); + if ($orderError) { + $alt = $orderError->getErrors(); + } + break; + case \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/resync.png', + $params + ); + $text = __('Resyncing'); + $menu = true; + break; + case \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED: + $url = $this->_assetRepository->getUrlWithParams( + 'Ebizmarts_MailChimp::images/never.png', + $params + ); + $text = __('With error'); + $alt = $item['mailchimp_sync_error']; + break; + default: + $url =''; + $text = ''; } $item['mailchimp_sync'] = "
$text
"; diff --git a/Ui/Component/Listing/Column/Products.php b/Ui/Component/Listing/Column/Products.php index 7461e73f..15fe95c0 100644 --- a/Ui/Component/Listing/Column/Products.php +++ b/Ui/Component/Listing/Column/Products.php @@ -5,7 +5,9 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; -use \Magento\Ui\Component\Listing\Columns\Column; +use Magento\Ui\Component\Listing\Columns\Column; +use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; + class Products extends Column { @@ -21,6 +23,10 @@ class Products extends Column * @var \Ebizmarts\MailChimp\Helper\Data */ protected $_helper; + /** + * @var SyncHelper + */ + private $syncHelper; /** * @var \Magento\Framework\View\Asset\Repository */ @@ -36,6 +42,7 @@ class Products extends Column * @param ProductFactory $productFactory * @param RequestInterface $requestInterface * @param \Ebizmarts\MailChimp\Helper\Data $helper + * @param SyncHelper $syncHelper * @param \Magento\Framework\View\Asset\Repository $assetRepository * @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory * @param array $components @@ -47,6 +54,7 @@ public function __construct( ProductFactory $productFactory, RequestInterface $requestInterface, \Ebizmarts\MailChimp\Helper\Data $helper, + SyncHelper $syncHelper, \Magento\Framework\View\Asset\Repository $assetRepository, \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory, array $components = [], @@ -55,6 +63,7 @@ public function __construct( $this->_productFactory = $productFactory; $this->_requestInterface = $requestInterface; $this->_helper = $helper; + $this->syncHelper = $syncHelper; $this->_assetRepository = $assetRepository; $this->_mailChimpErrorsFactory = $mailChimpErrorsFactory; parent::__construct($context, $uiComponentFactory, $components, $data); @@ -81,7 +90,7 @@ public function prepareDataSource(array $dataSource) \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, $product->getStoreId() ); - $syncData = $this->_helper->getChimpSyncEcommerce( + $syncData = $this->syncHelper->getChimpSyncEcommerce( $mailchimpStoreId, $product->getId(), \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT @@ -171,4 +180,4 @@ private function _getError($productId, $storeId) $error = $this->_mailChimpErrorsFactory->create(); return $error->getByStoreIdType($storeId, $productId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT); } -} \ No newline at end of file +}