diff --git a/Controller/Cart/Loadquote.php b/Controller/Cart/Loadquote.php index b379dfc..1b41b0f 100644 --- a/Controller/Cart/Loadquote.php +++ b/Controller/Cart/Loadquote.php @@ -98,7 +98,7 @@ public function __construct( Publisher $publisher, Contact $mauticContact ) { - + $this->pageFactory = $pageFactory; $this->_quote = $quote; $this->_customerSession = $customerSession; @@ -123,8 +123,9 @@ public function execute() $quote->getResource()->load($quote, $params['id']); $magentoStoreId = $quote->getStoreId(); $configSecretKey = $this->_helper->getConfig(\Lof\Mautic\Helper\Data::MODULE_ABANDONEDCART_TOKEN); + $tokenNew = $configSecretKey ? md5($configSecretKey.$params['id']) : ""; - if (!isset($params['token']) || $params['token'] != $configSecretKey) { + if (!isset($params['token']) || ($tokenNew && $params['token'] != $tokenNew)) { // @error $this->_message->addErrorMessage(__("You can't access this cart")); $url = $this->_urlHelper->getUrl( @@ -158,7 +159,7 @@ public function execute() if ($emailAddress = $quote->getCustomerEmail()) { $this->processUpdateContactTag($emailAddress, $quote->getStoreId()); } - + if (!$quote->getCustomerId()) { $this->_checkoutSession->setQuoteId($quote->getId()); $this->_redirect($url); @@ -185,7 +186,7 @@ public function execute() /** * process update contact tags - * + * * @param string $email * @param int|string|null $storeId * @return bool @@ -208,4 +209,4 @@ protected function processUpdateContactTag($email, $storeId = null) } return true; } -} \ No newline at end of file +} diff --git a/Queue/MessageQueues/SegmentAdd/Publisher.php b/Queue/MessageQueues/SegmentAdd/Publisher.php new file mode 100644 index 0000000..22f8caf --- /dev/null +++ b/Queue/MessageQueues/SegmentAdd/Publisher.php @@ -0,0 +1,13 @@ +_processAbandoned($storeId); } } - + return; } /** * Process abandoned cart - * + * * @param int $storeId * @return void */ protected function _processAbandoned($storeId) { $this->firstdate = $this->helperData->getConfig(Data::MODULE_FIRST_DATE, $storeId); + if (!$this->firstdate) { + $this->firstdate = $this->_getSuggestedZeroDate(); + } $this->customergroups = $this->helperData->getConfig(Data::MODULE_ABANDONED_CUSTOMER_GROUP, $storeId); $token = $this->helperData->getConfig(Data::MODULE_ABANDONEDCART_TOKEN, $storeId); @@ -99,6 +102,9 @@ protected function _processAbandoned($storeId) $this->customergroups = []; } $diff = $this->helperData->getConfig(Data::MODULE_DIFF_DATE, $storeId); + if (!$diff) { //Disable feature when diff date number is empty + return; + } $expr = sprintf('DATE_SUB(now(), %s)', $this->_getIntervalUnitSql($diff, 'DAY')); $from = new \Zend_Db_Expr($expr); @@ -119,7 +125,7 @@ protected function _processAbandoned($storeId) try { foreach ($collection as $quote) { - $tokenNew = $token;//.md5(rand(0, 9999999)); + $tokenNew = md5($token.$quote->getEntityId()); $url = $this->_storeManager->getStore($storeId)->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK) . 'mautic/cart/loadquote?id=' . $quote->getEntityId() . '&token=' . $tokenNew; $customData = [ @@ -142,7 +148,7 @@ protected function _processAbandoned($storeId) } catch (\Exception $e) { //log exception at here } - + return; } diff --git a/Queue/Processor/Segments/BestCustomersProcessor.php b/Queue/Processor/Segments/BestCustomersProcessor.php new file mode 100644 index 0000000..b44167e --- /dev/null +++ b/Queue/Processor/Segments/BestCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/BigSpendersProcessor.php b/Queue/Processor/Segments/BigSpendersProcessor.php new file mode 100644 index 0000000..087ebb8 --- /dev/null +++ b/Queue/Processor/Segments/BigSpendersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/LostCheapCustomersProcessor.php b/Queue/Processor/Segments/LostCheapCustomersProcessor.php new file mode 100644 index 0000000..c363870 --- /dev/null +++ b/Queue/Processor/Segments/LostCheapCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/LostCustomersProcessor.php b/Queue/Processor/Segments/LostCustomersProcessor.php new file mode 100644 index 0000000..e477574 --- /dev/null +++ b/Queue/Processor/Segments/LostCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/LowSpendersProcessor.php b/Queue/Processor/Segments/LowSpendersProcessor.php new file mode 100644 index 0000000..d1b63c0 --- /dev/null +++ b/Queue/Processor/Segments/LowSpendersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/LoyalCustomersProcessor.php b/Queue/Processor/Segments/LoyalCustomersProcessor.php new file mode 100644 index 0000000..d9fa041 --- /dev/null +++ b/Queue/Processor/Segments/LoyalCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/MidSpendersProcessor.php b/Queue/Processor/Segments/MidSpendersProcessor.php new file mode 100644 index 0000000..6a1403f --- /dev/null +++ b/Queue/Processor/Segments/MidSpendersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/NewCustomersProcessor.php b/Queue/Processor/Segments/NewCustomersProcessor.php new file mode 100644 index 0000000..f97db3e --- /dev/null +++ b/Queue/Processor/Segments/NewCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/OneTimePurchaseCustomersProcessor.php b/Queue/Processor/Segments/OneTimePurchaseCustomersProcessor.php new file mode 100644 index 0000000..126362e --- /dev/null +++ b/Queue/Processor/Segments/OneTimePurchaseCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/ThreeTimePurchaseCustomersProcessor.php b/Queue/Processor/Segments/ThreeTimePurchaseCustomersProcessor.php new file mode 100644 index 0000000..ada2ef2 --- /dev/null +++ b/Queue/Processor/Segments/ThreeTimePurchaseCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/Queue/Processor/Segments/TwoTimePurchaseCustomersProcessor.php b/Queue/Processor/Segments/TwoTimePurchaseCustomersProcessor.php new file mode 100644 index 0000000..aa4332d --- /dev/null +++ b/Queue/Processor/Segments/TwoTimePurchaseCustomersProcessor.php @@ -0,0 +1,77 @@ +collectionFactory = $collectionFactory; + $this->publisher = $publisher; + $this->_storeManager = $storeManager; + } + + /** + * @return void + */ + public function process() + { + //Write code at here + } +} diff --git a/README.md b/README.md index 810e7c9..7e04247 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,17 @@ - Support trigger events after save to sync data to Mautic - Support Console commands for Sync processing: Export customers, Export Orders, Export Reviews, Export Subscribers - Asynchronous Data Export: Support queue and cron job for calling Mautic APIs -- Includes abandon card tags (Comming Soon) +- Includes abandon card tags - Review reminder tags (Comming Soon) +## TO DO +- Review reminder tags (Comming Soon) +- Contact Segment (Comming soon) + + Add contact to a segment. Support common segment by reports: Best Customers, Big Spenders, Lost Cheap Customers, Lost Customers, Low Spenders, Loyal Customers, Mid Spenders, New Customers, One Time Purchase Customers, Two Time Purchase Customers, Three Time Purchase Customers. + + Remove contact from a segment +- Campaign Contact (Comming soon) +- Company Contact (Comming soon) + ## Installation \* = in production please use the `--keep-generated` option @@ -112,6 +120,7 @@ Require setup and config RabbitMQ for Magento 2 [RabbitMQ Configrable Guide](https://blog.landofcoder.com/how-to-set-up-and-configure-rabbitmq-with-magento-2/) + The module support there consummers: ``` @@ -121,6 +130,10 @@ mautic_review_save mautic_subscriber_save ``` +- Abandoned Cart Tags: +![Abandoned Cart Tags Settings](./assets/12_abandoned_cart.png) +the feature will run on each 5 minutes (cron job) find abandoned cart on reports which have last updated date <= Diff date number, and match customer groups (option), and updated date greater than first date (option). If found abandoned cart, it will add mautic contact with tag: AbandonedCart + ## Compatible Modules - [Magento 2 GDPR Compatible](https://github.com/landofcoder/module-magento2-mautic-gdpr) diff --git a/assets/12_abandoned_cart.png b/assets/12_abandoned_cart.png new file mode 100644 index 0000000..4118aa5 Binary files /dev/null and b/assets/12_abandoned_cart.png differ diff --git a/etc/communication.xml b/etc/communication.xml index d4cb719..db01713 100644 --- a/etc/communication.xml +++ b/etc/communication.xml @@ -5,4 +5,6 @@ + + diff --git a/etc/queue_consumer.xml b/etc/queue_consumer.xml index 4b330d5..26a75ff 100644 --- a/etc/queue_consumer.xml +++ b/etc/queue_consumer.xml @@ -13,4 +13,8 @@ + + + + diff --git a/etc/queue_publisher.xml b/etc/queue_publisher.xml index eb2ffbb..2faca49 100644 --- a/etc/queue_publisher.xml +++ b/etc/queue_publisher.xml @@ -19,4 +19,12 @@ + + + + + + + + diff --git a/etc/queue_topology.xml b/etc/queue_topology.xml index d05f75f..3ab8b40 100644 --- a/etc/queue_topology.xml +++ b/etc/queue_topology.xml @@ -26,4 +26,12 @@ + + + + + + + +