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

Dev #16

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Dev #16

Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions Controller/Cart/Loadquote.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(
Publisher $publisher,
Contact $mauticContact
) {

$this->pageFactory = $pageFactory;
$this->_quote = $quote;
$this->_customerSession = $customerSession;
Expand All @@ -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(
Expand Down Expand Up @@ -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);
Expand All @@ -185,7 +186,7 @@ public function execute()

/**
* process update contact tags
*
*
* @param string $email
* @param int|string|null $storeId
* @return bool
Expand All @@ -208,4 +209,4 @@ protected function processUpdateContactTag($email, $storeId = null)
}
return true;
}
}
}
13 changes: 13 additions & 0 deletions Queue/MessageQueues/SegmentAdd/Publisher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace Lof\Mautic\Queue\MessageQueues\SegmentAdd;

use Lof\Mautic\Queue\MessageQueues\AbstractPublisher;

class Publisher extends AbstractPublisher
{
/**
* {@inheritdoc}
*/
protected $_topic_name = 'mautic.magento.segment.add';
}
13 changes: 13 additions & 0 deletions Queue/MessageQueues/SegmentRemove/Publisher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace Lof\Mautic\Queue\MessageQueues\SegmentRemove;

use Lof\Mautic\Queue\MessageQueues\AbstractPublisher;

class Publisher extends AbstractPublisher
{
/**
* {@inheritdoc}
*/
protected $_topic_name = 'mautic.magento.segment.remove';
}
14 changes: 10 additions & 4 deletions Queue/Processor/AbandonedCartProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,22 @@ public function process()
$this->_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);

Expand All @@ -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);

Expand All @@ -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 = [
Expand All @@ -142,7 +148,7 @@ protected function _processAbandoned($storeId)
} catch (\Exception $e) {
//log exception at here
}

return;
}

Expand Down
77 changes: 77 additions & 0 deletions Queue/Processor/Segments/BestCustomersProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Lof\Mautic\Queue\Processor\Segments;

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreManager;
use Magento\Reports\Model\ResourceModel\Quote\CollectionFactory;
use Lof\Mautic\Model\Mautic\Contact;
use Lof\Mautic\Helper\Data;
use Lof\Mautic\Model\Mautic\AbstractApi;
use Lof\Mautic\Queue\MessageQueues\Order\Publisher;
use Lof\Mautic\Queue\Processor\AbstractQueueProcessor;

/**
* Class BestCustomersProcessor
* Find best customers from reports and add to segement name "Best Customers"
*/
class BestCustomersProcessor extends AbstractQueueProcessor
{
/**
* @var array
*/
protected $customergroups = [];

/**
* @var string|null
*/
protected $firstdate = null;

/**
* @var Publisher
*/
private $publisher;

/**
* @var CollectionFactory
*/
protected $collectionFactory;

/**
* @var StoreManager
*/
protected $_storeManager;


/**
* CategoryImport constructor.
*
* @param Contact $mauticContact
* @param Data $helperData
* @param CollectionFactory $collectionFactory
* @param Publisher $publisher
* @param StoreManager $storeManager
*/
public function __construct(
Contact $mauticContact,
Data $helperData,
CollectionFactory $collectionFactory,
Publisher $publisher,
StoreManager $storeManager
) {
parent::__construct($mauticContact, $helperData);
$this->collectionFactory = $collectionFactory;
$this->publisher = $publisher;
$this->_storeManager = $storeManager;
}

/**
* @return void
*/
public function process()
{
//Write code at here
}
}
77 changes: 77 additions & 0 deletions Queue/Processor/Segments/BigSpendersProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Lof\Mautic\Queue\Processor\Segments;

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreManager;
use Magento\Reports\Model\ResourceModel\Quote\CollectionFactory;
use Lof\Mautic\Model\Mautic\Contact;
use Lof\Mautic\Helper\Data;
use Lof\Mautic\Model\Mautic\AbstractApi;
use Lof\Mautic\Queue\MessageQueues\Order\Publisher;
use Lof\Mautic\Queue\Processor\AbstractQueueProcessor;

/**
* Class BigSpendersProcessor
* Find best customers from reports and add to segement name "Best Customers"
*/
class BigSpendersProcessor extends AbstractQueueProcessor
{
/**
* @var array
*/
protected $customergroups = [];

/**
* @var string|null
*/
protected $firstdate = null;

/**
* @var Publisher
*/
private $publisher;

/**
* @var CollectionFactory
*/
protected $collectionFactory;

/**
* @var StoreManager
*/
protected $_storeManager;


/**
* CategoryImport constructor.
*
* @param Contact $mauticContact
* @param Data $helperData
* @param CollectionFactory $collectionFactory
* @param Publisher $publisher
* @param StoreManager $storeManager
*/
public function __construct(
Contact $mauticContact,
Data $helperData,
CollectionFactory $collectionFactory,
Publisher $publisher,
StoreManager $storeManager
) {
parent::__construct($mauticContact, $helperData);
$this->collectionFactory = $collectionFactory;
$this->publisher = $publisher;
$this->_storeManager = $storeManager;
}

/**
* @return void
*/
public function process()
{
//Write code at here
}
}
77 changes: 77 additions & 0 deletions Queue/Processor/Segments/LostCheapCustomersProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace Lof\Mautic\Queue\Processor\Segments;

use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\Event\ManagerInterface;
use Magento\Store\Model\StoreManager;
use Magento\Reports\Model\ResourceModel\Quote\CollectionFactory;
use Lof\Mautic\Model\Mautic\Contact;
use Lof\Mautic\Helper\Data;
use Lof\Mautic\Model\Mautic\AbstractApi;
use Lof\Mautic\Queue\MessageQueues\Order\Publisher;
use Lof\Mautic\Queue\Processor\AbstractQueueProcessor;

/**
* Class LostCheapCustomersProcessor
* Find best customers from reports and add to segement name "Best Customers"
*/
class LostCheapCustomersProcessor extends AbstractQueueProcessor
{
/**
* @var array
*/
protected $customergroups = [];

/**
* @var string|null
*/
protected $firstdate = null;

/**
* @var Publisher
*/
private $publisher;

/**
* @var CollectionFactory
*/
protected $collectionFactory;

/**
* @var StoreManager
*/
protected $_storeManager;


/**
* CategoryImport constructor.
*
* @param Contact $mauticContact
* @param Data $helperData
* @param CollectionFactory $collectionFactory
* @param Publisher $publisher
* @param StoreManager $storeManager
*/
public function __construct(
Contact $mauticContact,
Data $helperData,
CollectionFactory $collectionFactory,
Publisher $publisher,
StoreManager $storeManager
) {
parent::__construct($mauticContact, $helperData);
$this->collectionFactory = $collectionFactory;
$this->publisher = $publisher;
$this->_storeManager = $storeManager;
}

/**
* @return void
*/
public function process()
{
//Write code at here
}
}
Loading
Loading