:::: MENU ::::

Magento Tutorial | Magento Blog | Learn Magento 2

Cookies Consent Popup

Try this code.

**system.xml**

    <field id="list_mode" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">

       <label>List Mode</label>        

       <source_model>Vendor\Module\Model\Config\Source\ListMode</source_model>

    </field>


**Vendor\Module\Model\Config\Source\ListMode.php**

  namespace Vendor\Module\Model\Config\Source;

    class ListMode implements \Magento\Framework\Data\OptionSourceInterface

    {

     public function toOptionArray()

     {

      return [

        ['value' => 'grid', 'label' => __('Grid Only')],

        ['value' => 'list', 'label' => __('List Only')],

        ['value' => 'grid-list', 'label' => __('Grid (default) / List')],

        ['value' => 'list-grid', 'label' => __('List (default) / Grid')]

      ];

     }

    }

0 comments:

Post a Comment