33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?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');
|
|
}
|
|
}
|