store.phtml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. // @codingStandardsIgnoreFile
  7. ?>
  8. <?php if ($websites = $block->getWebsites()): ?>
  9. <div class="field field-store-switcher">
  10. <label class="label" for="store_switcher"><?= $block->escapeHtml(__('Choose Store View:')) ?></label>
  11. <div class="control">
  12. <select
  13. id="store_switcher"
  14. class="admin__control-select"
  15. name="store_switcher">
  16. <?php foreach ($websites as $website): ?>
  17. <?php $showWebsite = false; ?>
  18. <?php foreach ($website->getGroups() as $group): ?>
  19. <?php $showGroup = false; ?>
  20. <?php foreach ($block->getStores($group) as $store): ?>
  21. <?php if ($showWebsite == false): ?>
  22. <?php $showWebsite = true; ?>
  23. <optgroup label="<?= $block->escapeHtmlAttr($website->getName()) ?>"></optgroup>
  24. <?php endif; ?>
  25. <?php if ($showGroup == false): ?>
  26. <?php $showGroup = true; ?>
  27. <optgroup label="&nbsp;&nbsp;&nbsp;<?= $block->escapeHtmlAttr($group->getName()) ?>">
  28. <?php endif; ?>
  29. <option value="<?= $block->escapeHtmlAttr($store->getId()) ?>"<?php if ($block->getStoreId() == $store->getId()): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?= $block->escapeHtml($store->getName()) ?></option>
  30. <?php endforeach; ?>
  31. <?php if ($showGroup): ?>
  32. </optgroup>
  33. <?php endif; ?>
  34. <?php endforeach; ?>
  35. <?php endforeach; ?>
  36. </select>
  37. </div>
  38. <?= $block->getHintHtml() ?>
  39. </div>
  40. <script>
  41. require(['prototype'], function(){
  42. //<![CDATA[
  43. Event.observe($('store_switcher'), 'change', function(event) {
  44. var element = Event.element(event);
  45. $('preview_store_id').value = element.value;
  46. });
  47. //]]>
  48. });
  49. </script>
  50. <?php endif; ?>