Skip to content

Commit

Permalink
MCS: use data patch instead of setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
vovayatsyuk committed Apr 7, 2022
1 parent 6f0bd18 commit 9cf04bb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 99 deletions.
53 changes: 0 additions & 53 deletions Setup/InstallData.php

This file was deleted.

63 changes: 63 additions & 0 deletions Setup/Patch/Data/CreateThumbnailAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Swissup\Easycatalogimg\Setup\Patch\Data;

use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Category\Attribute\Backend\Image;
use Magento\Catalog\Setup\CategorySetupFactory;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;

class CreateThumbnailAttribute implements DataPatchInterface, PatchVersionInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

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

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

public function apply()
{
$this->categorySetupFactory
->create(['setup' => $this->moduleDataSetup])
->addAttribute(Category::ENTITY, 'thumbnail', [
'type' => 'varchar',
'label' => 'Thumbnail',
'input' => 'image',
'backend' => Image::class,
'required' => false,
'sort_order' => 6,
'global' => ScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
}

public static function getVersion()
{
return '1.0.2';
}

public static function getDependencies()
{
return [];
}

public function getAliases()
{
return [];
}
}
46 changes: 0 additions & 46 deletions Setup/UpgradeData.php

This file was deleted.

1 comment on commit 9cf04bb

@ci-swissuplabs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! All tests are passed!

Please sign in to comment.