I have created a system.xml file with a multiselect type field somewhere in my admin system config. I just want to know on how to retrieve the selected values in that field?

  • I found the solution by using Mage::getStoreConfig(section_group_field path) Oct 24, 2017 at 9:41
  • bit.ly/2w7H6y2 using link got all the multiselect attribute. Aug 23, 2018 at 17:41

2 Answers 2


Define <source_model> in system.xml:

    <field id="Moduleposition" translate="Module" type="multiselect" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>Module Position</label>

Now create ConfigOption.php:


namespace Vendor\Module\Model\Config\Source;

use Magento\Framework\Data\OptionSourceInterface;

class ConfigOption implements OptionSourceInterface
    public function toOptionArray()
        return [
            ['value' => '1', 'label' => __('Top Right')],
            ['value' => '2', 'label' => __('Top Left')],
            ['value' => '3', 'label' => __('Middle Right')],
            ['value' => '4', 'label' => __('Middle')],
            ['value' => '5', 'label' => __('Middle Left')],
            ['value' => '6', 'label' => __('Bottom Right')],
            ['value' => '7', 'label' => __('Bottom Left')]

You will get multiselect value in string with value1,value2,value3 format.

You can use explode() function to convert it into array like this

    $value = explode(',', $multiSelectValue);

For more info about how you can get system.xml config value refer this question

Magento2 -How to get data from system configuration


Just like all the other values from your system.xml. The result will be a string with comma separated values. So you have explode the string and have an array for better handling like

$miltiselectValues = explode(',', $configValue);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.