1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Dotdigitalgroup\Email\Controller\Adminhtml\Run;
class Catalogsync extends \Magento\Backend\App\AbstractAction
{
/**
* Authorization level of a basic admin session
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = 'Dotdigitalgroup_Email::config';
/**
* @var \Magento\Framework\Message\ManagerInterface
*/
protected $messageManager;
/**
* @var \Dotdigitalgroup\Email\Model\Sync\CatalogFactory
*/
private $catalogFactory;
/**
* Catalogsync constructor.
*
* @param \Dotdigitalgroup\Email\Model\Sync\CatalogFactory $catalogFactory
* @param \Magento\Backend\App\Action\Context $context
*/
public function __construct(
\Dotdigitalgroup\Email\Model\Sync\CatalogFactory $catalogFactory,
\Magento\Backend\App\Action\Context $context
) {
$this->catalogFactory = $catalogFactory;
$this->messageManager = $context->getMessageManager();
parent::__construct($context);
}
/**
* Refresh suppressed contacts.
*
* @return null
*/
public function execute()
{
$result = $this->catalogFactory->create()
->sync();
$this->messageManager->addSuccessMessage($result['message']);
$redirectBack = $this->_redirect->getRefererUrl();
$this->_redirect($redirectBack);
}
}