2

How to show all store views on default store view and on other store views only the current store view shows. my code is

<?php

namespace PME\Hideprice\Model\Config\Source;
/**
* @api
* @since 100.0.2
*/
class Stores implements \Magento\Framework\Option\ArrayInterface
{
    public function __construct(
        \Magento\Store\Model\StoreManagerInterface $storeManager
    )
    {
        $this->_storeManager = $storeManager;
    }

    /**
    * 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;
   }


}

it shows all the store views on every store view I want to show all the store views only on default store view. Thanks in Advance

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.