init
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user