\!h Simple patch
<?php
namespace Test\Test\Setup\Patch\Data;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddTestOrderStatus implements DataPatchInterface
{
/**
* @var \Magento\Framework\Setup\ModuleDataSetupInterface
*/
private $moduleDataSetup;
/**
* @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
*/
public function __construct(
\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
) {
$this->moduleDataSetup = $moduleDataSetup;
}
/**
* {@inheritdoc}
*/
public function apply()
{
$this->moduleDataSetup->getConnection()->startSetup();
$this->moduleDataSetup->getConnection()->insertArray(
$this->moduleDataSetup->getTable('sales_order_status'),
['status', 'label'],
[['test', __('Test Processing')]]
);
$this->moduleDataSetup->getConnection()->insertArray(
$this->moduleDataSetup->getTable('sales_order_status_state'),
['status', 'state', 'is_default', 'visible_on_front'],
[['test','processing', '0', '1']]
);
$this->moduleDataSetup->getConnection()->endSetup();
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}
\!h Create a product attribute data patch with Magento 2.3's declarative schema
https://markshust.com/2019/02/19/create-product-attribute-data-patch-magento-2.3-declarative-schema/