Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-swatches
Setup
Patch
Data
AddSwatchImageAttribute.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Swatches\Setup\Patch\Data
;
8
9
use
Magento\Catalog\Model\Product\Attribute\Frontend\Image
;
10
use
Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface
;
11
use Magento\Eav\Setup\EavSetupFactory;
12
use
Magento\Eav\Setup\EavSetup
;
13
use
Magento\Framework\App\ResourceConnection
;
14
use
Magento\Framework\Setup\Patch\DataPatchInterface
;
15
use
Magento\Framework\Setup\Patch\PatchVersionInterface
;
16
21
class
AddSwatchImageAttribute
implements
DataPatchInterface
,
PatchVersionInterface
22
{
26
private
$moduleDataSetup;
27
31
private
$eavSetupFactory;
32
38
public
function
__construct
(
39
\
Magento
\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
40
EavSetupFactory $eavSetupFactory
41
) {
42
$this->moduleDataSetup = $moduleDataSetup;
43
$this->eavSetupFactory =
$eavSetupFactory
;
44
}
45
49
public
function
apply
()
50
{
52
$eavSetup
= $this->eavSetupFactory->create([
'setup'
=> $this->moduleDataSetup]);
53
57
$eavSetup
->addAttribute(
58
'catalog_product'
,
59
'swatch_image'
,
60
[
61
'type'
=>
'varchar'
,
62
'label'
=>
'Swatch'
,
63
'input'
=>
'media_image'
,
64
'frontend'
=> Image::class,
65
'required'
=>
false
,
66
'sort_order'
=> 3,
67
'global'
=>
ScopedAttributeInterface::SCOPE_STORE
,
68
'used_in_product_listing'
=>
true
69
]
70
);
71
}
72
76
public
static
function
getDependencies
()
77
{
78
return
[];
79
}
80
84
public
static
function
getVersion
()
85
{
86
return
'2.0.0'
;
87
}
88
92
public
function
getAliases
()
93
{
94
return
[];
95
}
96
}
Magento\Swatches\Setup\Patch\Data
Definition:
AddSwatchImageAttribute.php:7
Magento\Framework\Setup\Patch\DataPatchInterface
Definition:
DataPatchInterface.php:12
Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface
Definition:
ScopedAttributeInterface.php:12
Magento\Swatches\Setup\Patch\Data\AddSwatchImageAttribute\getDependencies
static getDependencies()
Definition:
AddSwatchImageAttribute.php:76
Magento\Swatches\Setup\Patch\Data\AddSwatchImageAttribute\getVersion
static getVersion()
Definition:
AddSwatchImageAttribute.php:84
Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface\SCOPE_STORE
const SCOPE_STORE
Definition:
ScopedAttributeInterface.php:14
Magento\Swatches\Setup\Patch\Data\AddSwatchImageAttribute
Definition:
AddSwatchImageAttribute.php:21
Magento\Swatches\Setup\Patch\Data\AddSwatchImageAttribute\getAliases
getAliases()
Definition:
AddSwatchImageAttribute.php:92
Magento\Catalog\Model\Product\Attribute\Frontend\Image
Definition:
Image.php:19
Magento\Swatches\Setup\Patch\Data\AddSwatchImageAttribute\__construct
__construct(\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory)
Definition:
AddSwatchImageAttribute.php:38
Magento\Framework\Setup\Patch\PatchInterface\apply
apply()
Magento
Magento\Eav\Setup\EavSetup
Definition:
EavSetup.php:25
Magento\Framework\Setup\Patch\PatchVersionInterface
Definition:
PatchVersionInterface.php:13
Magento\Framework\App\ResourceConnection
$eavSetupFactory
$eavSetupFactory
Definition:
product_for_search_rollback.php:21
$eavSetup
$eavSetup
Definition:
product_for_search_rollback.php:23