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-eav
Model
Attribute
Data
Select.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Eav\Model\Attribute\Data
;
7
8
use
Magento\Framework\App\RequestInterface
;
9
15
class
Select
extends
\Magento\Eav\Model\Attribute\Data\AbstractData
16
{
23
public
function
extractValue
(
RequestInterface
$request
)
24
{
25
return
$this->
_getRequestValue
($request);
26
}
27
35
public
function
validateValue
(
$value
)
36
{
37
$errors
= [];
38
$attribute
= $this->
getAttribute
();
39
40
if
(
$value
===
false
) {
41
// try to load original value and validate it
42
$value
= $this->
getEntity
()->getData(
$attribute
->getAttributeCode());
43
}
44
45
if
(
$attribute
->getIsRequired() && empty(
$value
) &&
$value
!=
'0'
) {
46
$label
=
__
(
$attribute
->getStoreLabel());
47
$errors
[] =
__
(
'"%1" is a required value.'
,
$label
);
48
}
49
50
if
(!
$errors
&& !
$attribute
->getIsRequired() && empty(
$value
)) {
51
return
true
;
52
}
53
54
if
(count(
$errors
) == 0) {
55
return
true
;
56
}
57
58
return
$errors
;
59
}
60
67
public
function
compactValue
(
$value
)
68
{
69
if
(
$value
!==
false
) {
70
$this->
getEntity
()->setData($this->
getAttribute
()->
getAttributeCode
(),
$value
);
71
}
72
return
$this;
73
}
74
82
public
function
restoreValue
(
$value
)
83
{
84
return
$this->
compactValue
(
$value
);
85
}
86
93
protected
function
_getOptionText
(
$value
)
94
{
95
return
$this->
getAttribute
()->getSource()->getOptionText(
$value
);
96
}
97
104
public
function
outputValue
(
$format
= \
Magento
\Eav\Model\
AttributeDataFactory::OUTPUT_FORMAT_TEXT
)
105
{
106
$value
= $this->
getEntity
()->getData($this->
getAttribute
()->
getAttributeCode
());
107
switch
(
$format
) {
108
case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON:
109
$output
=
$value
;
110
break
;
111
default
:
112
if
(
$value
!=
''
) {
113
$output
= $this->
_getOptionText
(
$value
);
114
}
else
{
115
$output
=
''
;
116
}
117
break
;
118
}
119
120
return
$output
;
121
}
122
}
Magento\Eav\Model\Attribute\Data\Select\restoreValue
restoreValue($value)
Definition:
Select.php:82
Magento\Eav\Model\Attribute\Data\Select\validateValue
validateValue($value)
Definition:
Select.php:35
Magento\Eav\Model\AttributeDataFactory\OUTPUT_FORMAT_TEXT
const OUTPUT_FORMAT_TEXT
Definition:
AttributeDataFactory.php:17
Magento\Eav\Model\Attribute\Data\Select\compactValue
compactValue($value)
Definition:
Select.php:67
Magento\Eav\Model\Attribute\Data\AbstractData\getEntity
getEntity()
Definition:
AbstractData.php:177
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
Magento\Eav\Model\Attribute\Data\AbstractData\_getRequestValue
_getRequestValue(RequestInterface $request)
Definition:
AbstractData.php:507
Magento\Eav\Model\Attribute\Data\AbstractData\getAttribute
getAttribute()
Definition:
AbstractData.php:123
__
__()
Definition:
__.php:13
Magento\Eav\Model\Attribute\Data
Definition:
AbstractData.php:7
Magento\Eav\Model\Attribute\Data\Select\extractValue
extractValue(RequestInterface $request)
Definition:
Select.php:23
$label
$label
Definition:
details.phtml:21
$value
$value
Definition:
gender.phtml:16
$format
$format
Definition:
list.phtml:12
Magento\Eav\Model\Attribute\Data\Select
Definition:
Select.php:15
Magento\Eav\Model\Entity\Attribute\AbstractAttribute\getAttributeCode
getAttributeCode()
Definition:
AbstractAttribute.php:321
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
Magento\Eav\Model\Attribute\Data\Select\_getOptionText
_getOptionText($value)
Definition:
Select.php:93
$output
$output
Definition:
classmap_generator.php:100
Magento
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
Magento\Eav\Model\Attribute\Data\Select\outputValue
outputValue($format=\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT)
Definition:
Select.php:104
$errors
$errors
Definition:
overview.phtml:9