Пример #1
0
 /**
  * @return array
  */
 public function toOptionArray()
 {
     if (!$this->_options) {
         $this->_options = [];
         foreach ($this->_storeManager->getWebsites() as $website) {
             $id = $website->getId();
             $name = $website->getName();
             if ($id != 0) {
                 $this->_options[] = ['value' => $id, 'label' => $name];
             }
         }
     }
     return $this->_options;
 }
Пример #2
0
 /**
  * Set correct scope if isSingleStoreMode = true
  *
  * @param \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig
  * @param \Magento\Framework\App\Config\ValueInterface $dataObject
  * @return void
  */
 protected function _checkSingleStoreMode(\Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig, $dataObject)
 {
     $isSingleStoreMode = $this->_storeManager->isSingleStoreMode();
     if (!$isSingleStoreMode) {
         return;
     }
     if (!$fieldConfig->showInDefault()) {
         $websites = $this->_storeManager->getWebsites();
         $singleStoreWebsite = array_shift($websites);
         $dataObject->setScope('websites');
         $dataObject->setWebsiteCode($singleStoreWebsite->getCode());
         $dataObject->setScopeCode($singleStoreWebsite->getCode());
         $dataObject->setScopeId($singleStoreWebsite->getId());
     }
 }