/** * {@inheritdoc} */ public function getAllowedStoreIds($scopeCode) { $stores = []; foreach ($this->storeRepository->getList() as $store) { if ($store->isActive()) { $stores[] = $store->getId(); } } return $stores; }
/** * {@inheritdoc} */ public function getAllowedStoreIds($scopeCode) { $stores = []; $website = $scopeCode ? $this->websiteRepository->get($scopeCode) : $this->websiteRepository->getDefault(); foreach ($this->storeRepository->getList() as $store) { if ($store->isActive() && $store->getWebsiteId() == $website->getId()) { $stores[] = $store->getId(); } } return $stores; }
/** * Prepares websites list with groups and stores as array * * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function getWebsitesList() { if (!empty($this->websitesList)) { return $this->websitesList; } $this->websitesList = []; $groupList = $this->groupRepository->getList(); $storesList = $this->storeRepository->getList(); foreach ($this->websiteRepository->getList() as $website) { $websiteId = $website->getId(); if (!$websiteId) { continue; } $websiteRow = ['id' => $websiteId, 'name' => $website->getName(), 'storesCount' => 0, 'groups' => []]; foreach ($groupList as $group) { $groupId = $group->getId(); if (!$groupId || $group->getWebsiteId() != $websiteId) { continue; } $groupRow = ['id' => $groupId, 'name' => $group->getName(), 'stores' => []]; foreach ($storesList as $store) { $storeId = $store->getId(); if (!$storeId || $store->getStoreGroupId() != $groupId) { continue; } $websiteRow['storesCount']++; $groupRow['stores'][] = ['id' => $storeId, 'name' => $store->getName()]; } $websiteRow['groups'][] = $groupRow; } $this->websitesList[] = $websiteRow; } return $this->websitesList; }
/** * Customize options * * @param array $meta * @return array */ private function customizeOptions($meta) { $sortOrder = 1; foreach ($this->storeRepository->getList() as $store) { $storeId = $store->getId(); $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]); $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['value_option_' . $storeId] = $this->arrayManager->set('arguments/data/config', [], ['dataType' => 'text', 'formElement' => 'input', 'component' => 'Magento_Catalog/js/form/element/input', 'template' => 'Magento_Catalog/form/element/input', 'prefixName' => 'option.value', 'prefixElementName' => 'option_', 'suffixName' => (string) $storeId, 'label' => $store->getName(), 'sortOrder' => $sortOrder, 'componentType' => Field::NAME]); ++$sortOrder; } $meta['attribute_options_select_container']['children']['attribute_options_select']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']); $meta['attribute_options_multiselect_container']['children']['attribute_options_multiselect']['children']['record']['children']['action_delete'] = $this->arrayManager->set('arguments/data/config', [], ['componentType' => 'actionDelete', 'dataType' => 'text', 'fit' => true, 'sortOrder' => $sortOrder, 'component' => 'Magento_Catalog/js/form/element/action-delete', 'elementTmpl' => 'Magento_Catalog/form/element/action-delete', 'template' => 'Magento_Catalog/form/element/action-delete', 'prefixName' => 'option.delete', 'prefixElementName' => 'option_']); return $meta; }
/** * {@inheritdoc} */ public function getStores($withDefault = false, $codeKey = false) { $stores = []; foreach ($this->storeRepository->getList() as $store) { if (!$withDefault && $store->getId() == 0) { continue; } if ($codeKey) { $stores[$store->getCode()] = $store; } else { $stores[$store->getId()] = $store; } } return $stores; }