init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Log;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::logs';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::logs');
|
||||
$page->getConfig()->getTitle()->prepend(__('Lingxing Synchronization Logs'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Log;
|
||||
|
||||
use Esun\LingxingErp\Model\Sync\DetailProvider;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class View extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::logs';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly PageFactory $pageFactory,
|
||||
private readonly DetailProvider $detailProvider
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Page|Redirect
|
||||
{
|
||||
$record = $this->detailProvider->getRecord('log', (int)$this->getRequest()->getParam('id'));
|
||||
if ($record === null) {
|
||||
$this->messageManager->addErrorMessage(__('The synchronization log no longer exists.'));
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::logs');
|
||||
$page->getConfig()->getTitle()->prepend(__('Synchronization Log #%1', $record['entity_id']));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Order;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::orders';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::orders');
|
||||
$page->getConfig()->getTitle()->prepend(__('Lingxing Order Synchronization'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Order;
|
||||
|
||||
use Esun\LingxingErp\Model\Sync\DetailProvider;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class View extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::orders';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly PageFactory $pageFactory,
|
||||
private readonly DetailProvider $detailProvider
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Page|Redirect
|
||||
{
|
||||
$record = $this->detailProvider->getRecord('order', (int)$this->getRequest()->getParam('id'));
|
||||
if ($record === null) {
|
||||
$this->messageManager->addErrorMessage(__('The order synchronization record no longer exists.'));
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::orders');
|
||||
$page->getConfig()->getTitle()->prepend(__('Order Synchronization #%1', $record['increment_id']));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Shipment;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::shipments';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::shipments');
|
||||
$page->getConfig()->getTitle()->prepend(__('Lingxing Shipment Synchronization'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Shipment;
|
||||
|
||||
use Esun\LingxingErp\Model\Sync\DetailProvider;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
use Magento\Framework\View\Result\Page;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class View extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::shipments';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly PageFactory $pageFactory,
|
||||
private readonly DetailProvider $detailProvider
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Page|Redirect
|
||||
{
|
||||
$record = $this->detailProvider->getRecord('shipment', (int)$this->getRequest()->getParam('id'));
|
||||
if ($record === null) {
|
||||
$this->messageManager->addErrorMessage(__('The shipment synchronization record no longer exists.'));
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::shipments');
|
||||
$page->getConfig()->getTitle()->prepend(__('Shipment Synchronization #%1', $record['wo_number']));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Sku;
|
||||
|
||||
use Esun\LingxingErp\Model\Sku\SkuSynchronizer;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class Sync extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::sync_sku_mappings';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly SkuSynchronizer $synchronizer)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$summary = $this->synchronizer->synchronizeAll();
|
||||
if ($summary['errors'] !== []) {
|
||||
$this->messageManager->addErrorMessage(__(
|
||||
'ERP SKU synchronization completed with %1 Website error(s). Review Synchronization Logs.',
|
||||
count($summary['errors'])
|
||||
));
|
||||
}
|
||||
$this->messageManager->addSuccessMessage(__(
|
||||
'Processed %1 Website(s) and %2 pair(s): %3 mapped, %4 products remain without an ERP SKU.',
|
||||
$summary['websites'],
|
||||
$summary['pairs'],
|
||||
$summary['mapped'],
|
||||
$summary['unmapped']
|
||||
));
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage(__('ERP SKU synchronization failed: %1', $exception->getMessage()));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setPath('esun_lingxing/store/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Store;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::stores';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly PageFactory $pageFactory)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$page = $this->pageFactory->create();
|
||||
$page->setActiveMenu('Esun_LingxingErp::store_list');
|
||||
$page->getConfig()->getTitle()->prepend(__('Lingxing Stores'));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Store;
|
||||
|
||||
use Esun\LingxingErp\Model\Store\StoreSynchronizer;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\App\Action\HttpGetActionInterface;
|
||||
|
||||
class Sync extends Action implements HttpGetActionInterface
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::sync_stores';
|
||||
|
||||
public function __construct(Action\Context $context, private readonly StoreSynchronizer $synchronizer)
|
||||
{
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$count = $this->synchronizer->synchronize();
|
||||
$this->messageManager->addSuccessMessage(__('Synchronized %1 Lingxing stores.', $count));
|
||||
} catch (\Throwable $exception) {
|
||||
$this->messageManager->addErrorMessage(__('Store synchronization failed: %1', $exception->getMessage()));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setPath('*/*/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\LingxingErp\Controller\Adminhtml\Sync;
|
||||
|
||||
use Esun\LingxingErp\Model\Sync\OrderSyncRepository;
|
||||
use Esun\LingxingErp\Model\Sync\ShipmentSyncRepository;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Framework\Controller\Result\Redirect;
|
||||
|
||||
class Retry extends Action
|
||||
{
|
||||
public const ADMIN_RESOURCE = 'Esun_LingxingErp::retry';
|
||||
|
||||
public function __construct(
|
||||
Action\Context $context,
|
||||
private readonly OrderSyncRepository $orderRepository,
|
||||
private readonly ShipmentSyncRepository $shipmentRepository
|
||||
) {
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute(): Redirect
|
||||
{
|
||||
$id = (int)$this->getRequest()->getParam('id');
|
||||
$type = (string)$this->getRequest()->getParam('type');
|
||||
$retried = $type === 'order'
|
||||
? $this->orderRepository->retry($id)
|
||||
: ($type === 'shipment' && $this->shipmentRepository->retry($id));
|
||||
if ($retried) {
|
||||
$this->messageManager->addSuccessMessage(__('The synchronization was queued for retry.'));
|
||||
} else {
|
||||
$this->messageManager->addErrorMessage(__('This record cannot be retried in its current state.'));
|
||||
}
|
||||
return $this->resultRedirectFactory->create()->setRefererUrl();
|
||||
}
|
||||
}
|
||||
@@ -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