ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use JR\NetSuite\Queue\ProductQueueManager;
|
||||
|
||||
/**
|
||||
* Class ClearHistory from controller
|
||||
*/
|
||||
class Fetch extends \Magento\Backend\App\Action
|
||||
{
|
||||
const MENU_ID = 'JR_NetSuite::productqueue';
|
||||
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @var ProductQueueManager
|
||||
*/
|
||||
protected $productQueueManager;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
|
||||
ProductQueueManager $productQueueManager
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
$this->productQueueManager = $productQueueManager;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$result = $this->productQueueManager->fetchAndEnqueue(true);
|
||||
|
||||
if ($result['error']) {
|
||||
$this->messageManager->addErrorMessage(__('Error while fetching data from NetSuite. ' . $result['message']));
|
||||
} else {
|
||||
$this->messageManager->addSuccessMessage(__('Data fetched successfully. ' . $result['message']));
|
||||
}
|
||||
$this->_redirect('jr_netsuite/productqueue/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed(static::MENU_ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use JR\NetSuite\Cron\ProductSyncCron;
|
||||
|
||||
/**
|
||||
* Class ClearHistory from controller
|
||||
*/
|
||||
class Import extends \Magento\Backend\App\Action
|
||||
{
|
||||
const MENU_ID = 'JR_NetSuite::productqueue';
|
||||
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @var ProductSyncCron
|
||||
*/
|
||||
protected $productSyncCron;
|
||||
|
||||
/**
|
||||
* @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,
|
||||
ProductSyncCron $productSyncCron
|
||||
) {
|
||||
$this->_resource = $resource;
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
$this->productSyncCron = $productSyncCron;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$processed = 0;
|
||||
$loopCount = 0;
|
||||
do {
|
||||
$count = $this->productSyncCron->processQueueItems();
|
||||
if ($count) {
|
||||
$processed += $count;
|
||||
}
|
||||
$loopCount++;
|
||||
} while ($count);
|
||||
$this->messageManager->addSuccessMessage(__('A total of %1 product queues processed.', $processed));
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
}
|
||||
$this->_redirect('jr_netsuite/productqueue/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed(static::MENU_ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
class Index extends ProductQueue
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\View\Result\PageFactory
|
||||
*/
|
||||
private $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
PageFactory $resultPageFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the page defined in view/adminhtml/layout/jr_netsuite_productqueue_index.xml
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var Page $resultPage */
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$resultPage->setActiveMenu('JR_NetSuite::productqueue');
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Product Queue'));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @category JR
|
||||
* @package JR_NetSuite
|
||||
* @author JR Software Private Limited
|
||||
* @copyright Copyright (c) JR Software Private Limited (https://JR.com)
|
||||
* @license https://store.JR.com/license.html
|
||||
*/
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use JR\NetSuite\Model\ResourceModel\ProductQueue\CollectionFactory;
|
||||
|
||||
class MassDelete extends \Magento\Backend\App\Action
|
||||
{
|
||||
/**
|
||||
* Massactions filter.
|
||||
*
|
||||
* @var Filter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
private $collectionFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Filter $filter
|
||||
* @param CollectionFactory $collectionFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->filter = $filter;
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute action
|
||||
*
|
||||
* @return \Magento\Backend\Model\View\Result\Redirect
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$collection = $this->filter->getCollection($this->collectionFactory->create());
|
||||
$accountsCount = 0;
|
||||
foreach ($collection->getItems() as $account) {
|
||||
$this->deleteObj($account);
|
||||
++$accountsCount;
|
||||
}
|
||||
$this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $accountsCount));
|
||||
|
||||
return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('*/*/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete object.
|
||||
*
|
||||
* @param mixed $object
|
||||
* @return void
|
||||
*/
|
||||
private function deleteObj($object)
|
||||
{
|
||||
$object->delete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use JR\NetSuite\Cron\ProductSyncCron;
|
||||
|
||||
/**
|
||||
* Class ClearHistory from controller
|
||||
*/
|
||||
class Schedule extends \Magento\Backend\App\Action
|
||||
{
|
||||
const MENU_ID = 'JR_NetSuite::productqueue';
|
||||
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
protected $resultPageFactory;
|
||||
|
||||
/**
|
||||
* @var ProductSyncCron
|
||||
*/
|
||||
protected $productSyncCron;
|
||||
|
||||
/**
|
||||
* @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,
|
||||
ProductSyncCron $productSyncCron
|
||||
) {
|
||||
$this->_resource = $resource;
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
$this->productSyncCron = $productSyncCron;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$result = $this->productSyncCron->scheduleCronJob();
|
||||
if (!$result) {
|
||||
throw new \Exception('Cron job could not be scheduled.');
|
||||
}
|
||||
$this->messageManager->addSuccessMessage(__('Cron job created successfully. Please wait for the product to be imported.'));
|
||||
} catch (\Exception $e) {
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
}
|
||||
$this->_redirect('jr_netsuite/productqueue/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed(static::MENU_ID);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace JR\NetSuite\Controller\Adminhtml\ProductQueue;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use JR\NetSuite\Model\ResourceModel\ProductQueueFactory;
|
||||
|
||||
/**
|
||||
* Class ViewJson
|
||||
*/
|
||||
class View extends \Magento\Backend\App\Action
|
||||
{
|
||||
const MENU_ID = 'JR_NetSuite::productqueue';
|
||||
|
||||
/**
|
||||
* @var PageFactory
|
||||
*/
|
||||
protected $resultPageFactory = false;
|
||||
|
||||
/**
|
||||
* @var ProductQueueFactory
|
||||
*/
|
||||
protected $productQueueFactory;
|
||||
|
||||
/**
|
||||
* Index constructor.
|
||||
*
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
ProductQueueFactory $productQueueFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->productQueueFactory = $productQueueFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the page defined in json form
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
|
||||
$entity_id = $this->getRequest()->getParam('entity_id');
|
||||
|
||||
if ($entity_id > 0) {
|
||||
$prductQueue = $this->productQueueFactory->create()->load($entity_id);
|
||||
if ($prductQueue) {
|
||||
$resJson = $prductQueue->getData('data');
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(200);
|
||||
exit($resJson);
|
||||
}
|
||||
|
||||
}
|
||||
$this->messageManager->addErrorMessage(__('No record found!'));
|
||||
$this->_redirect('jrnetsuite/productqueue/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow modules
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function _isAllowed()
|
||||
{
|
||||
return $this->_authorization->isAllowed('JR_NetSuite::product_queue');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user