To add the customer attribute programmatically in Magento 2, you need to follow these steps:
- Create the Setup File InstallData.ph
- Create the Source File
<?php
namespace Company\Mymodule\Model\Source;class Customdropdown extends \Magento\Eav\Model\Entity\Attribute\Source\Abstrac tSource { public function getAllOptions() { if ($this->_options === null) { $this->_options = [ ['value' => '', 'label' => __('Please Select')], ['value' => '1', 'label' => __('Google')], ['value' => '2', 'label' => __('Friend')], ['value' => '3', 'label' => __('Email')], ['value' => '4', 'label' => __('Other')] ]; } return $this->_options; } public function getOptionText($value) { foreach ($this->getAllOptions() as $option) { if ($option['value'] == $value) { return $option['label']; } } return false; } }
- Upgrade
For more information adding or creating customer attribute programmatically in Magento 2, visit the following blog:
Magento 2 Add Customer Attribute ProgrammaticallyView more threads in the same category:
- buy a USA/UK passport online( https://legitcleandocs.com)visa, SNN, id card
- buy registered drivers license (legitcleandocs.com)IELTS, id
- Modalert 200 - Treat Your Oversleeping Issue
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- buy real drivers license(https://legitcleandocs.com)buy Austria id card, passports
- Buy registered passport and driver's license online
- buy real passports online(https://legitcleandocs.com)drivers license, visa, id card
- BUY UNDETECTABLE GRADE A+ COUNTERFEIT BANKNOTE(legitcleandocs.com)
- Connecting the Dots: How to Get Magento 2 API Keys
Bookmarks