0

I have this basic class that I use in my UpgradeData script

class Industry extends AbstractSource

    {
    /**
     * Retrieve All options
     *
     * @return array[]
     */
    public function getAllOptions()
    {
        $industries = [
            "Accommodation",
            "Administration of Economic Programs",
            "Administration of Environmental Quality Programs",
            "Administration of Housing Programs, Urban Planning",
            "Administration of Human Resource Programs",
            "...",
            // and so on, over 100 total
        ];
        if (!$this->_options) {
            $this->_options = [];
            foreach ($industries as $index => $value) {
                $this->_options[] = ['value' => $index, 'label' => $value];
            }
        }
        return $this->_options;
    }
}

Which I use as the 'source' model for my $eavSetUp->addAttribute. It works fine, gets added to the customer EAV table and saves when you adjust it. But I have over 100 potential 'default' options for the custom attribute.

Is there a cleaner way to do this than storing a 100 line array in the AbstractSource extended class?

  • Yes, you can make cleaner by using these 100 values stored in the system configuration and get those value here. Let me know if you want any more help. Thanks – Shankar Jan 26 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.