125 private $frontendLabelFactory;
140 private $emptyStringTypes = [
152 private $eavExtensionFactory;
178 \
Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
191 \
Magento\Eav\Api\Data\AttributeExtensionFactory $eavExtensionFactory =
null,
192 FrontendLabelFactory $frontendLabelFactory =
null 204 $this->_eavTypeFactory = $eavTypeFactory;
206 $this->_resourceHelper = $resourceHelper;
207 $this->_universalFactory = $universalFactory;
212 ->get(\
Magento\Eav\Api\Data\AttributeExtensionFactory::class);
213 $this->frontendLabelFactory = $frontendLabelFactory
226 if ($this->serializer ===
null) {
254 \Magento\Framework\Profiler::start(
'load_by_code');
264 throw new LocalizedException(
__(
'The entity supplied is invalid. Verify the entity and try again.'));
268 \Magento\Framework\Profiler::stop(
'load_by_code');
281 return $this->
_getData(
'attribute_code');
293 $this->_data[
'attribute_id'] =
$data;
304 return $this->
_getData(
'attribute_id');
323 return $this->
_getData(
'attribute_code');
342 return $this->
_getData(
'attribute_model');
361 return $this->
_getData(
'backend_type');
380 return $this->
_getData(
'backend_model');
400 return $this->
_getData(
'is_visible_on_front');
409 return $this->
_getData(
'default_value');
421 return $this->
setData(
'default_value', $defaultValue);
430 return $this->
_getData(
'attribute_set_id');
440 $this->_data[
'attribute_set_id'] =
$id;
451 return $this->
_getData(
'entity_type_id');
461 $this->_data[
'entity_type_id'] =
$id;
539 if (!$this->_entity) {
554 return $this->
getEntity()->getValueEntityIdField();
565 if (empty($this->_backend)) {
573 'The "%1" backend model is invalid. Verify the backend model and try again.',
578 $this->_backend = $backend->setAttribute($this);
591 if (empty($this->_frontend)) {
592 if (!$this->getFrontendModel()) {
595 $this->_frontend = $this->_universalFactory->create($this->getFrontendModel())->setAttribute($this);
609 if (empty($this->_source)) {
617 'Source model "%1" not found for attribute "%2"',
623 $this->_source =
$source->setAttribute($this);
638 return $input ===
'select' || $input ===
'multiselect' || $this->
_getData(
'source_model') !=
'';
647 return \Magento\Eav\Model\Entity::DEFAULT_BACKEND_MODEL;
656 return \Magento\Eav\Model\Entity::DEFAULT_FRONTEND_MODEL;
665 return $this->
getEntityType()->getEntity()->getDefaultAttributeSourceModel();
679 || (
$value === self::EMPTY_STRING && $this->isInEmptyStringTypes());
699 private function isInEmptyStringTypes()
712 if (!$this->hasAttributeSetInfo()) {
716 if (is_array($setId) && count(array_intersect($setId, array_keys($this->getAttributeSetInfo())))) {
720 if (!is_array($setId) && array_key_exists($setId, $this->getAttributeSetInfo())) {
736 $dataPath = sprintf(
'attribute_set_info/%s/group_id', $setId);
753 $cacheKey =
"{$entityType}|{$code}";
754 if (!isset($this->_attributeIdCache[$cacheKey])) {
758 return $this->_attributeIdCache[$cacheKey];
778 if ($this->_dataTable ===
null) {
780 $this->_dataTable = $this->
getEntityType()->getValueTablePrefix();
782 $backendTable = trim($this->
_getData(
'backend_table'));
783 if (empty($backendTable)) {
787 $this->_dataTable = $backendTable;
803 return $this->
getSource()->getFlatColumns();
825 $type = $prop[
'DATA_TYPE'];
826 $size = $prop[
'LENGTH'] ? $prop[
'LENGTH'] :
null;
829 'type' => $this->_resourceHelper->getDdlTypeByColumnType(
$type),
831 'unsigned' => $prop[
'UNSIGNED'] ? true :
false,
832 'nullable' => $prop[
'NULLABLE'],
833 'default' => $prop[
'DEFAULT'],
911 'type' => $prop[
'DATA_TYPE'] . ($prop[
'LENGTH'] ?
"({$prop['LENGTH']})" :
""),
912 'unsigned' => $prop[
'UNSIGNED'] ?
true :
false,
913 'is_null' => $prop[
'NULLABLE'],
914 'default' => $prop[
'DEFAULT'],
920 'type' =>
'datetime',
929 'type' =>
'decimal(12,4)',
956 'type' =>
'varchar(255)',
978 $condition = $this->getUsedForSortBy();
979 if ($this->getFlatAddFilterableAttributes()) {
980 $condition = $condition || $this->getIsFilterable();
985 return $this->
getSource()->getFlatIndexes();
1018 if (in_array($prop[
'DATA_TYPE'], $indexDataTypes)) {
1020 $indexes[$indexName] = [
'type' =>
'index',
'fields' => [$this->
getAttributeCode()]];
1029 $indexes[$indexName] = [
'type' =>
'index',
'fields' => [$this->
getAttributeCode()]];
1050 foreach ($this->_storeManager->getStores() as
$store) {
1074 return $this->
_getData(self::IS_UNIQUE);
1085 return $this->
setData(self::IS_UNIQUE, $isUnique);
1093 return $this->
_getData(self::FRONTEND_CLASS);
1104 return $this->
setData(self::FRONTEND_CLASS, $frontendClass);
1112 return $this->
_getData(self::FRONTEND_INPUT);
1120 return $this->
setData(self::FRONTEND_INPUT, $frontendInput);
1128 return $this->
_getData(self::IS_REQUIRED);
1136 return $this->
setData(self::IS_REQUIRED, $isRequired);
1151 return $this->convertToObjects(
$options);
1163 $optionDataArray = [];
1165 $optionData = $this->dataObjectProcessor->buildOutputDataArray(
1167 \
Magento\Eav\Api\Data\AttributeOptionInterface::class
1171 $this->
setData(self::OPTIONS, $optionDataArray);
1185 protected function convertToObjects(array
$options)
1190 $optionDataObject = $this->optionDataFactory->create();
1191 $this->dataObjectHelper->populateWithArray(
1194 \
Magento\Eav\Api\Data\AttributeOptionInterface::class
1196 $dataObjects[] = $optionDataObject;
1199 return $dataObjects;
1208 return $this->
getData(self::IS_USER_DEFINED);
1219 return $this->
setData(self::IS_USER_DEFINED, $isUserDefined);
1227 return $this->
_getData(self::FRONTEND_LABEL);
1238 return $this->
setData(self::FRONTEND_LABEL, $defaultFrontendLabel);
1246 if ($this->
getData(self::FRONTEND_LABELS) ==
null) {
1248 $storeLabels = $this->
_getResource()->getStoreLabelsByAttributeId($attributeId);
1250 $resultFrontedLabels = [];
1251 foreach ($storeLabels as
$i =>
$label) {
1252 $frontendLabel = $this->frontendLabelFactory->create();
1253 $frontendLabel->setStoreId(
$i);
1254 $frontendLabel->setLabel(
$label);
1255 $resultFrontedLabels[] = $frontendLabel;
1257 $this->
setData(self::FRONTEND_LABELS, $resultFrontedLabels);
1259 return $this->
_getData(self::FRONTEND_LABELS);
1270 return $this->
setData(self::FRONTEND_LABELS, $frontendLabels);
1278 return $this->
_getData(self::NOTE);
1297 return $this->
_getData(self::SOURCE_MODEL);
1308 return $this->
setData(self::SOURCE_MODEL, $sourceModel);
1337 return $this->
setData(self::VALIDATE_RULES, $validationRules);
1382 '_universalFactory',
1383 'optionDataFactory',
1384 'dataObjectProcessor',
1407 $this->optionDataFactory =
$objectManager->get(\
Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class);
1408 $this->dataObjectProcessor =
$objectManager->get(\
Magento\Framework\Reflection\DataObjectProcessor::class);
isInGroup($setId, $groupId)
_getDefaultBackendModel()
_getFlatColumnsOldDefinition()
getDefaultFrontendLabel()
setDefaultValue($defaultValue)
setIsUserDefined($isUserDefined)
_getExtensionAttributes()
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory $optionDataFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], \Magento\Eav\Api\Data\AttributeExtensionFactory $eavExtensionFactory=null, FrontendLabelFactory $frontendLabelFactory=null)
_getFlatColumnsDdlDefinition()
elseif(isset( $params[ 'redirect_parent']))
getIdByCode($entityType, $code)
loadByCode($entityType, $code)
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
setValidationRules(array $validationRules=null)
setIsRequired($isRequired)
setExtensionAttributes(\Magento\Eav\Api\Data\AttributeExtensionInterface $extensionAttributes)
setFrontendInput($frontendInput)
setFrontendLabels(array $frontendLabels=null)
setSourceModel($sourceModel)
getFlatUpdateSelect($store=null)
getData($key='', $index=null)
setFrontendClass($frontendClass)
setData($key, $value=null)
isAllowedEmptyTextValue($value)
_getDefaultFrontendModel()
setDefaultFrontendLabel($defaultFrontendLabel)
setOptions(array $options=null)
if(!isset($_GET['name'])) $name