init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Warehouse;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::warehouses';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::warehouses');
|
||||
$page->getConfig()->getTitle()->prepend(__('Lingxing Warehouses and Inventory'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Warehouse;
|
||||
|
||||
use Esun\LingxingErp\Model\Warehouse\WarehouseSynchronizer;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class Sync extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::sync_warehouses';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly WarehouseSynchronizer $synchronizer)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$result = $this->synchronizer->synchronize();
|
||||
$this->messageManager->addSuccessMessage(__(
|
||||
'Synchronized %1 Lingxing type 3 warehouses. Magento Inventory Sources were not created or changed.',
|
||||
$result['warehouses']
|
||||
));
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage(__('Warehouse synchronization failed: %1', $exception->getMessage()));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Warehouse;
|
||||
|
||||
use Esun\LingxingErp\Model\Inventory\InventorySynchronizer;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class SyncInventory extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::sync_inventory';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly InventorySynchronizer $synchronizer)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$result = $this->synchronizer->synchronizeAll();
|
||||
if ($result['errors'] !== []) {
|
||||
$this->messageManager->addWarningMessage(__(
|
||||
'Inventory synchronized for %1 warehouses and %2 items, with %3 warehouse errors. See Synchronization Logs.',
|
||||
$result['warehouses'],
|
||||
$result['items'],
|
||||
count($result['errors'])
|
||||
));
|
||||
} else {
|
||||
$this->messageManager->addSuccessMessage(__(
|
||||
'Inventory synchronized for %1 warehouses and %2 items. Unmapped ERP SKUs: %3.',
|
||||
$result['warehouses'],
|
||||
$result['items'],
|
||||
$result['unmapped']
|
||||
));
|
||||
}
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage(__('Inventory synchronization failed: %1', $exception->getMessage()));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setPath('esun_lingxing/warehouse/index');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user