ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace JR\NetSuite\Controller\Adminhtml\CustomerQueue;
|
||||
|
||||
class InlineEdit extends \Magento\Backend\App\Action
|
||||
{
|
||||
|
||||
protected $jsonFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\App\Action\Context $context
|
||||
* @param \Magento\Framework\Controller\Result\JsonFactory $jsonFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Backend\App\Action\Context $context,
|
||||
\Magento\Framework\Controller\Result\JsonFactory $jsonFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
$this->jsonFactory = $jsonFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inline edit action
|
||||
*
|
||||
* @return \Magento\Framework\Controller\ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
|
||||
$resultJson = $this->jsonFactory->create();
|
||||
$error = false;
|
||||
$messages = [];
|
||||
|
||||
if ($this->getRequest()->getParam('isAjax')) {
|
||||
$postItems = $this->getRequest()->getParam('items', []);
|
||||
if (!count($postItems)) {
|
||||
$messages[] = __('Please correct the data sent.');
|
||||
$error = true;
|
||||
} else {
|
||||
foreach (array_keys($postItems) as $modelid) {
|
||||
/** @var \JR\NetSuite\Model\CustomerQueue $model */
|
||||
$model = $this->_objectManager->create(\JR\NetSuite\Model\CustomerQueue::class)->load($modelid);
|
||||
try {
|
||||
$model->setData(array_merge($model->getData(), $postItems[$modelid]));
|
||||
$model->save();
|
||||
} catch (\Exception $e) {
|
||||
$messages[] = "[Customer Queue ID: {$modelid}] {$e->getMessage()}";
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $resultJson->setData([
|
||||
'messages' => $messages,
|
||||
'error' => $error
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user