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