36 lines
1.0 KiB
PHP
36 lines
1.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\LingxingErp\Cron;
|
|
|
|
use Esun\LingxingErp\Model\Config;
|
|
use Esun\LingxingErp\Model\Sku\SkuSynchronizer;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class SyncSkuMappings
|
|
{
|
|
public function __construct(
|
|
private readonly Config $config,
|
|
private readonly SkuSynchronizer $synchronizer,
|
|
private readonly LoggerInterface $logger
|
|
) {
|
|
}
|
|
|
|
public function execute(): void
|
|
{
|
|
if (!$this->config->isEnabled() || !$this->config->isSkuSyncEnabled()) {
|
|
return;
|
|
}
|
|
try {
|
|
$summary = $this->synchronizer->synchronizeAll();
|
|
if ($summary['errors'] !== []) {
|
|
$this->logger->error('Lingxing ERP SKU synchronization completed with Website errors.', [
|
|
'errors' => $summary['errors'],
|
|
]);
|
|
}
|
|
} catch (\Throwable $exception) {
|
|
$this->logger->error('Lingxing ERP SKU synchronization failed.', ['exception' => $exception]);
|
|
}
|
|
}
|
|
}
|