Files
esun3d/app/code/Esun/LingxingErp/Controller/Adminhtml/Store/Sync.php
T
2026-09-15 10:35:56 +08:00

30 lines
983 B
PHP

<?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');
}
}