0

How to create Store View in System.xml. I can explain it with image given below enter image description here

0

Got it... create new class in

Vender\Module\Model\Config\Source

<?php

namespace Vender\Module\Model\Config\Source;
/**
* @api
* @since 100.0.2
*/
class Stores implements \Magento\Framework\Option\ArrayInterface
{
   /**
    * Options getter
    *
    * @return array
    */
   public function toOptionArray()
   {

       $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
       $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');

       $storeManagerDataList = $storeManager->getStores();
       $options = array();

        foreach ($storeManagerDataList as $key => $value)
        {
              $options[] = ['label' => $value['name'],  'value' => $key ];
        }
        return $options;
   }

}

after that in configuration (System.xml)

Vender\Module\etc\adminhtml\system.xml add these lines

<field id="storeview" translate="label" type="multiselect"
                    sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Hide for StoreViews</label>
                    <comment>Product price will be hidden for the selected StoreViews only.</comment>
                    <source_model>Vender\Module\Model\Config\Source\Stores</source_model>
                    <depends>
                        <field id="enabled">1</field>
                    </depends>
                </field>

enter image description here

then you'll get storetypes in configuration.

Your Answer

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

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