ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace JR\NetSuite\Controller\Adminhtml\CustomerQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use JR\NetSuite\Cron\CustomerSyncCron;
|
||||
|
||||
/**
|
||||
* Class ClearHistory from controller
|
||||
*/
|
||||
class Import extends \Magento\Backend\App\Action
|
||||
{
|
||||
const MENU_ID = 'JR_NetSuite::customerqueue';
|
||||
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @var CustomerSyncCron
|
||||
*/
|
||||
protected $customerSyncCron;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\ResourceConnection
|
||||
*/
|
||||
protected $_resource;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\App\ResourceConnection $resource,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
|
||||
CustomerSyncCron $customerSyncCron
|
||||
) {
|
||||
$this->_resource = $resource;
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
$this->customerSyncCron = $customerSyncCron;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$processed = 0;
|
||||
do {
|
||||
$count = $this->customerSyncCron->processQueueItems();
|
||||
if ($count) {
|
||||
$processed += $count;
|
||||
}
|
||||
} while ($count);
|
||||
$this->messageManager->addSuccessMessage(__('A total of %1 customers imported.', $processed));
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
}
|
||||
$this->_redirect('jr_netsuite/customerqueue/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed(static::MENU_ID);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user