How to override the core "module-store/Setup/Patch/Data/DisableSid.php" into "app/code/Mymodule/Test/" module. can anyone please help me.
Thanks
You cannot rewrite this Patch data this way.
Patch data are run one time. So override is NOT the solution for this.
I guess that you want to make web/session/use_frontend_sid
field value to 1
So, create A data patch on your custom module: and change this field value to 1.
<?php
namespace {VendorName}\{ModuleName}\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\App\Config\MutableScopeConfigInterface;
class {ClassName} implements DataPatchInterface
{
const SCOPE_STORE = 'store';
/**
* @var \Magento\Framework\App\Config\MutableScopeConfigInterface
*/
private $mutableScopeConfig;
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
MutableScopeConfigInterface $mutableScopeConfig
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->mutableScopeConfig = $mutableScopeConfig;
}
public function apply()
{
$this->moduleDataSetup->startSetup();
$this->mutableScopeConfig->setValue(self::XML_PATH_USE_FRONTEND_SID, 1, self::SCOPE_STORE);
$this->moduleDataSetup->endSetup();
}
public function getAliases()
{
return [];
}
public static function getDependencies()
{
return [];
}
}
@Amit Bera is right.
The override Data Patch is not the solution. because it makes an issue on setup:upgrade command.
The plugin and preference are not working Data patch file. So if you want to add changes to your existing core or any vendor third-party module. You need to create a custom patch.
Create a custom patch click here
Or you can create a new patch to fix the old one by adding dependencies.
Add dependent patch file below function.
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [
\VedoreName\ModuleName\Setup\Patch\Data\AddPatchFileName::class,
];
}