1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Swatches\Setup\Patch\Data;
- use Magento\Eav\Setup\EavSetupFactory;
- use Magento\Catalog\Model\Product;
- use Magento\Framework\App\ResourceConnection;
- use Magento\Framework\Setup\Patch\DataPatchInterface;
- use Magento\Framework\Setup\Patch\PatchVersionInterface;
- /**
- * Class AddSwatchImageToDefaultAttribtueSet
- * @package Magento\Swatches\Setup\Patch
- */
- class AddSwatchImageToDefaultAttribtueSet implements DataPatchInterface, PatchVersionInterface
- {
- /**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface
- */
- private $moduleDataSetup;
- /**
- * @var EavSetupFactory
- */
- private $eavSetupFactory;
- /**
- * PatchInitial constructor.
- * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
- */
- public function __construct(
- \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
- EavSetupFactory $eavSetupFactory
- ) {
- $this->moduleDataSetup = $moduleDataSetup;
- $this->eavSetupFactory = $eavSetupFactory;
- }
- /**
- * {@inheritdoc}
- */
- public function apply()
- {
- $this->moduleDataSetup->getConnection()->startSetup();
- /** @var \Magento\Eav\Setup\EavSetup $eavSetup */
- $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
- $attributeSetId = $eavSetup->getDefaultAttributeSetId(Product::ENTITY);
- $groupId = (int)$eavSetup->getAttributeGroupByCode(
- Product::ENTITY,
- $attributeSetId,
- 'image-management',
- 'attribute_group_id'
- );
- $eavSetup->addAttributeToGroup(Product::ENTITY, $attributeSetId, $groupId, 'swatch_image');
- $this->moduleDataSetup->getConnection()->endSetup();
- }
- /**
- * {@inheritdoc}
- */
- public static function getDependencies()
- {
- return [
- AddSwatchImageAttribute::class
- ];
- }
- /**
- * {@inheritdoc}
- */
- public static function getVersion()
- {
- return '2.0.1';
- }
- /**
- * {@inheritdoc}
- */
- public function getAliases()
- {
- return [];
- }
- }
|