This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace Esun\OrderNumber\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
class Config
{
public const XML_PATH_SITE_NAME = 'sales/order_number/site_name';
public const XML_PATH_START_NUMBER = 'sales/order_number/start_number';
public function __construct(
private readonly ScopeConfigInterface $scopeConfig,
private readonly StoreManagerInterface $storeManager
) {
}
public function getSiteName(int $websiteId): string
{
$configuredName = trim((string)$this->scopeConfig->getValue(
self::XML_PATH_SITE_NAME,
ScopeInterface::SCOPE_WEBSITE,
$websiteId
));
if ($configuredName !== '') {
return $configuredName;
}
return (string)$this->storeManager->getWebsite($websiteId)->getCode();
}
public function getStartNumber(int $websiteId): int
{
return max(1, (int)$this->scopeConfig->getValue(
self::XML_PATH_START_NUMBER,
ScopeInterface::SCOPE_WEBSITE,
$websiteId
));
}
}