当前位置: 首页>>代码示例>>PHP>>正文


PHP Store::getStoreCollection方法代码示例

本文整理汇总了PHP中Magento\Store\Model\System\Store::getStoreCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Store::getStoreCollection方法的具体用法?PHP Store::getStoreCollection怎么用?PHP Store::getStoreCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Store\Model\System\Store的用法示例。


在下文中一共展示了Store::getStoreCollection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateCurrentOptions

 /**
  * Generate current options
  *
  * @return void
  */
 protected function generateCurrentOptions()
 {
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     $groupCollection = $this->systemStore->getGroupCollection();
     $storeCollection = $this->systemStore->getStoreCollection();
     /** @var \Magento\Store\Model\Website $website */
     foreach ($websiteCollection as $website) {
         $groups = [];
         /** @var \Magento\Store\Model\Group $group */
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() == $website->getId()) {
                 $stores = [];
                 /** @var  \Magento\Store\Model\Store $store */
                 foreach ($storeCollection as $store) {
                     if ($store->getGroupId() == $group->getId()) {
                         $name = $this->escaper->escapeHtml($store->getName());
                         $stores[$name]['label'] = str_repeat(' ', 8) . $name;
                         $stores[$name]['value'] = $store->getId();
                     }
                 }
                 if (!empty($stores)) {
                     $name = $this->escaper->escapeHtml($group->getName());
                     $groups[$name]['label'] = str_repeat(' ', 4) . $name;
                     $groups[$name]['value'] = array_values($stores);
                 }
             }
         }
         if (!empty($groups)) {
             $name = $this->escaper->escapeHtml($website->getName());
             $this->currentOptions[$name]['label'] = $name;
             $this->currentOptions[$name]['value'] = array_values($groups);
         }
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:39,代码来源:Options.php

示例2: addRatingFieldset

 /**
  * Add rating fieldset to form
  *
  * @return void
  */
 protected function addRatingFieldset()
 {
     $this->initFieldset('rating_form', ['legend' => __('Rating Title')]);
     $this->getFieldset('rating_form')->addField('rating_code', 'text', ['name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true]);
     foreach ($this->systemStore->getStoreCollection() as $store) {
         $this->getFieldset('rating_form')->addField('rating_code_' . $store->getId(), 'text', ['label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']']);
     }
     $this->setRatingData();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:Form.php

示例3: _prepareForm

 /**
  * Prepare rating edit form
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $this->setForm($form);
     $fieldset = $form->addFieldset('rating_form', array('legend' => __('Rating Title')));
     $fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true));
     foreach ($this->_systemStore->getStoreCollection() as $store) {
         $fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
     }
     if ($this->_session->getRatingData()) {
         $form->setValues($this->_session->getRatingData());
         $data = $this->_session->getRatingData();
         if (isset($data['rating_codes'])) {
             $this->_setRatingCodes($data['rating_codes']);
         }
         $this->_session->setRatingData(null);
     } elseif ($this->_coreRegistry->registry('rating_data')) {
         $form->setValues($this->_coreRegistry->registry('rating_data')->getData());
         if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
             $this->_setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
         }
     }
     if ($this->_coreRegistry->registry('rating_data')) {
         $collection = $this->_optionFactory->create()->getResourceCollection()->addRatingFilter($this->_coreRegistry->registry('rating_data')->getId())->load();
         $i = 1;
         foreach ($collection->getItems() as $item) {
             $fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
             $i++;
         }
     } else {
         for ($i = 1; $i <= 5; $i++) {
             $fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
         }
     }
     $fieldset = $form->addFieldset('visibility_form', array('legend' => __('Rating Visibility')));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('stores', 'multiselect', array('label' => __('Visible In'), 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
         if ($this->_coreRegistry->registry('rating_data')) {
             $form->getElement('stores')->setValue($this->_coreRegistry->registry('rating_data')->getStores());
         }
     }
     $fieldset->addField('is_active', 'checkbox', array('label' => __('Is Active'), 'name' => 'is_active', 'value' => 1));
     $fieldset->addField('position', 'text', array('label' => __('Sort Order'), 'name' => 'position'));
     if ($this->_coreRegistry->registry('rating_data')) {
         $form->getElement('position')->setValue($this->_coreRegistry->registry('rating_data')->getPosition());
         $form->getElement('is_active')->setIsChecked($this->_coreRegistry->registry('rating_data')->getIsActive());
     }
     return parent::_prepareForm();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:57,代码来源:Form.php

示例4: getHtml

 /**
  * Render HTML of the element
  *
  * @return string
  */
 public function getHtml()
 {
     $websiteCollection = $this->_systemStore->getWebsiteCollection();
     $groupCollection = $this->_systemStore->getGroupCollection();
     $storeCollection = $this->_systemStore->getStoreCollection();
     $allShow = $this->getColumn()->getStoreAll();
     $html = '<select name="' . $this->escapeHtml($this->_getHtmlName()) . '" ' . $this->getColumn()->getValidateClass() . $this->getUiId('filter', $this->_getHtmlName()) . '>';
     $value = $this->getColumn()->getValue();
     if ($allShow) {
         $html .= '<option value="0"' . ($value == 0 ? ' selected="selected"' : '') . '>' . __('All Store Views') . '</option>';
     } else {
         $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
     }
     foreach ($websiteCollection as $website) {
         $websiteShow = false;
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() != $website->getId()) {
                 continue;
             }
             $groupShow = false;
             foreach ($storeCollection as $store) {
                 if ($store->getGroupId() != $group->getId()) {
                     continue;
                 }
                 if (!$websiteShow) {
                     $websiteShow = true;
                     $html .= '<optgroup label="' . $this->escapeHtml($website->getName()) . '"></optgroup>';
                 }
                 if (!$groupShow) {
                     $groupShow = true;
                     $html .= '<optgroup label="&nbsp;&nbsp;&nbsp;&nbsp;' . $this->escapeHtml($group->getName()) . '">';
                 }
                 $value = $this->getValue();
                 $selected = $value == $store->getId() ? ' selected="selected"' : '';
                 $html .= '<option value="' . $store->getId() . '"' . $selected . '>&nbsp;&nbsp;&nbsp;&nbsp;' . $this->escapeHtml($store->getName()) . '</option>';
             }
             if ($groupShow) {
                 $html .= '</optgroup>';
             }
         }
     }
     if ($this->getColumn()->getDisplayDeleted()) {
         $selected = $this->getValue() == '_deleted_' ? ' selected' : '';
         $html .= '<option value="_deleted_"' . $selected . '>' . __('[ deleted ]') . '</option>';
     }
     $html .= '</select>';
     return $html;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:53,代码来源:Store.php

示例5: toOptionArray

 /**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     if ($this->options !== null) {
         return $this->options;
     }
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     $groupCollection = $this->systemStore->getGroupCollection();
     $storeCollection = $this->systemStore->getStoreCollection();
     $currentOptions = [];
     /** @var \Magento\Store\Model\Website $website */
     foreach ($websiteCollection as $website) {
         $groups = [];
         /** @var \Magento\Store\Model\Group $group */
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() == $website->getId()) {
                 $stores = [];
                 /** @var  \Magento\Store\Model\Store $store */
                 foreach ($storeCollection as $store) {
                     if ($store->getGroupId() == $group->getId()) {
                         $name = $this->escaper->escapeHtml($store->getName());
                         $stores[$name]['label'] = str_repeat(' ', 8) . $name;
                         $stores[$name]['value'] = $store->getId();
                     }
                 }
                 if (!empty($stores)) {
                     $name = $this->escaper->escapeHtml($group->getName());
                     $groups[$name]['label'] = str_repeat(' ', 4) . $name;
                     $groups[$name]['value'] = array_values($stores);
                 }
             }
         }
         if (!empty($groups)) {
             $name = $this->escaper->escapeHtml($website->getName());
             $currentOptions[$name]['label'] = $name;
             $currentOptions[$name]['value'] = array_values($groups);
         }
     }
     $this->options = array_values($currentOptions);
     return $this->options;
 }
开发者ID:nja78,项目名称:magento2,代码行数:45,代码来源:Options.php

示例6: generateCurrentOptions

 /**
  * Generate current options
  *
  * @return void
  */
 protected function generateCurrentOptions()
 {
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     $groupCollection = $this->systemStore->getGroupCollection();
     $storeCollection = $this->systemStore->getStoreCollection();
     // Add option to select All Websites
     $this->currentOptions['All Websites']['label'] = $this->escaper->escapeHtml(__('All Websites'));
     $this->currentOptions['All Websites']['value'] = \Magento\Search\Ui\Component\Listing\Column\Website\Options::ALL_WEBSITES . ':' . \Magento\Store\Model\Store::DEFAULT_STORE_ID;
     foreach ($websiteCollection as $website) {
         $groups = [];
         /** @var \Magento\Store\Model\Group $group */
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() == $website->getId()) {
                 $stores = [];
                 /** @var  \Magento\Store\Model\Store $store */
                 // Add an option for All store views for this website
                 $stores['All Store Views']['label'] = $this->escaper->escapeHtml(__('    All Store Views'));
                 $stores['All Store Views']['value'] = $website->getId() . ':' . \Magento\Store\Model\Store::DEFAULT_STORE_ID;
                 /** @var \Magento\Store\Model\Website $website */
                 foreach ($storeCollection as $store) {
                     if ($store->getGroupId() == $group->getId()) {
                         $name = $this->escaper->escapeHtml($store->getName());
                         $stores[$name]['label'] = str_repeat(' ', 8) . $name;
                         $stores[$name]['value'] = $website->getId() . ':' . $store->getId();
                     }
                 }
                 // Add parent Store group
                 $name = $this->escaper->escapeHtml($group->getName());
                 $groups[$name]['label'] = str_repeat(' ', 4) . $name;
                 $groups[$name]['value'] = array_values($stores);
             }
         }
         $name = $this->escaper->escapeHtml($website->getName());
         $this->currentOptions[$name]['label'] = $name;
         $this->currentOptions[$name]['value'] = array_values($groups);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:42,代码来源:Options.php

示例7: getOptions

 /**
  * Get options
  *
  * @param array $options
  * @return array
  */
 public function getOptions(array $options = [])
 {
     $websiteCollection = $this->systemStore->getWebsiteCollection();
     $groupCollection = $this->systemStore->getGroupCollection();
     $storeCollection = $this->systemStore->getStoreCollection();
     $currentOptions = [__('All Store Views') => ['label' => __('All Store Views'), 'value' => 0]];
     /** @var \Magento\Store\Model\Website $website */
     foreach ($websiteCollection as $website) {
         $groups = [];
         /** @var \Magento\Store\Model\Group $group */
         foreach ($groupCollection as $group) {
             if ($group->getWebsiteId() == $website->getId()) {
                 $stores = [];
                 /** @var  \Magento\Store\Model\Store $store */
                 foreach ($storeCollection as $store) {
                     if ($store->getGroupId() == $group->getId()) {
                         $name = $this->escaper->escapeHtml($store->getName());
                         $stores[$name]['label'] = str_repeat(' ', 8) . $name;
                         $stores[$name]['value'] = $store->getId();
                     }
                 }
                 if (!empty($stores)) {
                     $name = $this->escaper->escapeHtml($group->getName());
                     $groups[$name]['label'] = str_repeat(' ', 4) . $name;
                     $groups[$name]['value'] = $stores;
                 }
             }
         }
         if (!empty($groups)) {
             $name = $this->escaper->escapeHtml($website->getName());
             $currentOptions[$name]['label'] = $name;
             $currentOptions[$name]['value'] = $groups;
         }
     }
     return array_merge_recursive($currentOptions, $options);
 }
开发者ID:,项目名称:,代码行数:42,代码来源:

示例8: _processWebsite

 /**
  * Process website info
  *
  * @param \Magento\Store\Model\System\Store $storeModel
  * @param \Magento\Store\Model\Website $website
  * @param string $section
  * @param string $curStore
  * @param string $curWebsite
  * @param array $options
  * @return array
  */
 protected function _processWebsite(\Magento\Store\Model\System\Store $storeModel, \Magento\Store\Model\Website $website, $section, $curStore, $curWebsite, array $options)
 {
     $websiteShow = false;
     foreach ($storeModel->getGroupCollection() as $group) {
         if ($group->getWebsiteId() != $website->getId()) {
             continue;
         }
         $groupShow = false;
         foreach ($storeModel->getStoreCollection() as $store) {
             if ($store->getGroupId() != $group->getId()) {
                 continue;
             }
             if (!$websiteShow) {
                 $websiteShow = true;
                 $options['website_' . $website->getCode()] = array('label' => $website->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode())), 'selected' => !$curStore && $curWebsite == $website->getCode(), 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;');
             }
             if (!$groupShow) {
                 $groupShow = true;
                 $options['group_' . $group->getId() . '_open'] = array('is_group' => true, 'is_close' => false, 'label' => $group->getName(), 'style' => 'padding-left:32px;');
             }
             $options['store_' . $store->getCode()] = array('label' => $store->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode(), 'store' => $store->getCode())), 'selected' => $curStore == $store->getCode(), 'style' => '');
         }
         if ($groupShow) {
             $options['group_' . $group->getId() . '_close'] = array('is_group' => true, 'is_close' => true);
         }
     }
     return $options;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:39,代码来源:Switcher.php


注:本文中的Magento\Store\Model\System\Store::getStoreCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。