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
Observer
AddFieldsToAttributeObserver.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Swatches\Observer
;
7
8
use
Magento\Config\Model\Config\Source
;
9
use
Magento\Framework\Module\Manager
;
10
use
Magento\Framework\Event\Observer
as
EventObserver
;
11
use
Magento\Framework\Event\ObserverInterface
;
12
16
class
AddFieldsToAttributeObserver
implements
ObserverInterface
17
{
21
protected
$yesNo
;
22
26
protected
$moduleManager
;
27
32
public
function
__construct
(
Manager
$moduleManager
, Source\
Yesno
$yesNo
)
33
{
34
$this->moduleManager =
$moduleManager
;
35
$this->yesNo =
$yesNo
;
36
}
37
42
public
function
execute
(
EventObserver
$observer
)
43
{
44
if
(!$this->moduleManager->isOutputEnabled(
'Magento_Swatches'
)) {
45
return
;
46
}
47
49
$form =
$observer
->getForm();
50
$fieldset = $form->getElement(
'base_fieldset'
);
51
$yesnoSource = $this->yesNo->toOptionArray();
52
$fieldset->addField(
53
'update_product_preview_image'
,
54
'select'
,
55
[
56
'name'
=>
'update_product_preview_image'
,
57
'label'
=>
__
(
'Update Product Preview Image'
),
58
'title'
=>
__
(
'Update Product Preview Image'
),
59
'note'
=>
__
(
'Filtering by this attribute will update the product image on catalog page'
),
60
'values'
=> $yesnoSource,
61
],
62
'is_filterable'
63
);
64
$fieldset->addField(
65
'use_product_image_for_swatch'
,
66
'select'
,
67
[
68
'name'
=>
'use_product_image_for_swatch'
,
69
'label'
=>
__
(
'Use Product Image for Swatch if Possible'
),
70
'title'
=>
__
(
'Use Product Image for Swatch if Possible'
),
71
'note'
=>
__
(
'Allows use fallback logic for replacing swatch image with product swatch or base image'
),
72
'values'
=> $yesnoSource
73
],
74
'is_filterable'
75
);
76
}
77
}
Magento\Swatches\Observer
Definition:
AddFieldsToAttributeObserver.php:6
Magento\Swatches\Observer\AddFieldsToAttributeObserver\$yesNo
$yesNo
Definition:
AddFieldsToAttributeObserver.php:21
Magento\Config\Model\Config\Source
Magento\Framework\Event\ObserverInterface
Definition:
ObserverInterface.php:16
__
__()
Definition:
__.php:13
Magento\Config\Model\Config\Source\Yesno
Definition:
Yesno.php:12
$observer
$observer
Definition:
second_website_with_second_currency.php:38
Magento\Swatches\Observer\AddFieldsToAttributeObserver
Definition:
AddFieldsToAttributeObserver.php:16
Magento\Framework\Event\Observer
Definition:
Collection.php:12
Magento\Swatches\Observer\AddFieldsToAttributeObserver\__construct
__construct(Manager $moduleManager, Source\Yesno $yesNo)
Definition:
AddFieldsToAttributeObserver.php:32
Magento\Framework\Module\Manager
Definition:
Manager.php:20
Magento\Framework\Event\ObserverInterface\execute
execute(Observer $observer)
Magento\Swatches\Observer\AddFieldsToAttributeObserver\$moduleManager
$moduleManager
Definition:
AddFieldsToAttributeObserver.php:26