Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php


namespace Magento\Catalog\Setup\Patch\Data;


use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;

/**
* Class UpdateDefaultCategoryIsActive
* @package Magento\Catalog\Setup\Patch\Data
*/
class UpdateDefaultCategoryIsActive implements DataPatchInterface, PatchVersionInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var CategorySetupFactory
*/
private $categorySetupFactory;

/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param CategorySetupFactory $categorySetupFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
CategorySetupFactory $categorySetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->categorySetupFactory = $categorySetupFactory;
}

/**
* @inheritdoc
*/
public function apply()
{
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
$rootCategoryId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;

// Create Root Catalog Node
$categorySetup->createCategory()
->load($rootCategoryId)
->setIsActive(1)
->save();

return $this;
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [
SetNewResourceModelsPaths::class,
];
}

/**
* @inheritdoc
*/
public static function getVersion()
{
return '2.4.1';
}

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}