In magento 2.3.1, I created custom eav_entity_type and attribute also assign under that custom eav_entity_type.
Now, I added attribute options programmatically in that attribute and that record I saved in eav_attribute_options and eav_attribute_options_value tables.
Now, I used this below code for get that all options. But, I return blank array.
/*Get attribute details*/
$attributeDetails = $this->eavConfig->getAttribute("custom_eav_entity_type", 'custom_eav_attr');
print_r($attributeDetails->getData()); //return blanks
How do I get that all options?
Any help would be appriciated.
Thanks.
-
You mean you want to get attribute type where it is Select, text etc...?Chirag Patel– Chirag Patel2019年05月09日 11:44:58 +00:00Commented May 9, 2019 at 11:44
-
No. I added attribute in custom eav_entity_type and my custom attribute save under custom eav_entity_type. For ex: color attribute save under catalog_product eav_entity_type.Emipro Technologies Pvt. Ltd.– Emipro Technologies Pvt. Ltd.2019年05月09日 12:55:26 +00:00Commented May 9, 2019 at 12:55
1 Answer 1
Try this
$attribute = $this->eavConfig->getAttribute('eav_entity_type_code', 'attributecode');
$attributeoptions = $attribute->getSource()->getAllOptions();
I hope this will help
-
That's working. But, I want from custom eav_entity_type.Emipro Technologies Pvt. Ltd.– Emipro Technologies Pvt. Ltd.2019年05月09日 11:03:33 +00:00Commented May 9, 2019 at 11:03
-
@EmiproTechnologiesPvt.Ltd. In that case, replace
catalog_productwith your customeav_entity_type_code. If it's still not work, so check this tutorial techjeffyu.com/blog/magento-2-creating-new-eav-entity-and-model may be you miss some thing during creation of custom eav_entity_typeMuhammad Hasham– Muhammad Hasham2019年05月09日 11:13:56 +00:00Commented May 9, 2019 at 11:13