-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MCS: use data patch instead of setup scripts
- Loading branch information
1 parent
6f0bd18
commit 9cf04bb
Showing
3 changed files
with
63 additions
and
99 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 []; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
9cf04bb
There was a problem hiding this comment.
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!