40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Customer\Setup\Patch\Data;
|
|
|
|
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
|
use Magento\Framework\Setup\Patch\DataPatchInterface;
|
|
use Magento\Sales\Model\Order;
|
|
use Magento\Sales\Model\Order\StatusFactory;
|
|
|
|
class AddReceivedOrderStatus implements DataPatchInterface
|
|
{
|
|
public function __construct(
|
|
private readonly ModuleDataSetupInterface $moduleDataSetup,
|
|
private readonly StatusFactory $statusFactory
|
|
) {
|
|
}
|
|
|
|
public function apply(): self
|
|
{
|
|
$this->moduleDataSetup->getConnection()->startSetup();
|
|
$status = $this->statusFactory->create()->load('received');
|
|
if (!$status->getStatus()) {
|
|
$status->setData(['status' => 'received', 'label' => 'Received'])->save();
|
|
}
|
|
$status->assignState(Order::STATE_COMPLETE, false, true);
|
|
$this->moduleDataSetup->getConnection()->endSetup();
|
|
return $this;
|
|
}
|
|
|
|
public static function getDependencies(): array
|
|
{
|
|
return [AddShippedOrderStatus::class];
|
|
}
|
|
public function getAliases(): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|