本文整理汇总了PHP中Magento\Store\Model\System\Store::getWebsiteCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Store::getWebsiteCollection方法的具体用法?PHP Store::getWebsiteCollection怎么用?PHP Store::getWebsiteCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Store\Model\System\Store
的用法示例。
在下文中一共展示了Store::getWebsiteCollection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例2: getStoreSelectOptions
/**
* Retrieve list of available stores
*
* @return array
*/
public function getStoreSelectOptions()
{
$section = $this->getRequest()->getParam('section');
$curWebsite = $this->getRequest()->getParam('website');
$curStore = $this->getRequest()->getParam('store');
$options = array();
$options['default'] = array('label' => __('Default Config'), 'url' => $this->getUrl('*/*/*', array('section' => $section)), 'selected' => !$curWebsite && !$curStore, 'style' => 'background:#ccc; font-weight:bold;');
foreach ($this->_systemStore->getWebsiteCollection() as $website) {
$options = $this->_processWebsite($this->_systemStore, $website, $section, $curStore, $curWebsite, $options);
}
return $options;
}
示例3: toOptionArray
/**
* Get options
*
* @return array
*/
public function toOptionArray()
{
$currentOptions['']['label'] = '--';
$currentOptions['']['value'] = '--';
$currentOptions['All Store Views']['label'] = __('All Websites');
$currentOptions['All Store Views']['value'] = self::ALL_WEBSITES;
$websiteCollection = $this->systemStore->getWebsiteCollection();
foreach ($websiteCollection as $website) {
$name = $this->escaper->escapeHtml($website->getName());
$currentOptions[$name]['label'] = $name;
$currentOptions[$name]['value'] = $website->getId();
}
$this->options = array_values($currentOptions);
return $currentOptions;
}
示例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=" ' . $this->escapeHtml($group->getName()) . '">';
}
$value = $this->getValue();
$selected = $value == $store->getId() ? ' selected="selected"' : '';
$html .= '<option value="' . $store->getId() . '"' . $selected . '> ' . $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;
}
示例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;
}
示例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);
}
}
示例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);
}