Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes #225 #231

Open
wants to merge 3 commits into from

5 participants

@fbrnc
Collaborator

No Selenium tests so far. But all the existing tests using the grid would be obsolete then.

This patch renders a hierarchical tree structure of websites, stores and store view and replaces the grid in "System > Configuration"

@therouv
Collaborator

:+1:

@mcspronko

Useless code should not be deleted. Such code should be marked as deprecated.

@mcspronko mcspronko was assigned
@verklov

Approved by PO.

@mage2-team mage2-team referenced this pull request in magento/magento2
Closed

Request: Improve store view, name etc overview #318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 10, 2013
  1. Removed obsolete grid for System > Manage Stores

    Fabrizio Branca authored
This page is out of date. Refresh to see the latest.
View
84 app/code/core/Mage/Adminhtml/Block/System/Store/Grid.php
@@ -1,84 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-
-/**
- * Adminhtml store grid
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @author Magento Core Team <core@magentocommerce.com>
- */
-class Mage_Adminhtml_Block_System_Store_Grid extends Mage_Adminhtml_Block_Widget_Grid
-{
-
- public function __construct()
- {
- parent::__construct();
- $this->setId('storeGrid');
- $this->setSaveParametersInSession(true);
- }
-
- protected function _prepareCollection()
- {
- $collection = Mage::getModel('core/website')
- ->getCollection()
- ->joinGroupAndStore();
- $this->setCollection($collection);
- parent::_prepareCollection();
- return $this;
- }
-
- protected function _prepareColumns()
- {
- $this->addColumn('website_title', array(
- 'header' => Mage::helper('core')->__('Website Name'),
- 'align' =>'left',
- 'index' => 'name',
- 'filter_index' => 'main_table.name',
- 'renderer' => 'adminhtml/system_store_grid_render_website'
- ));
-
- $this->addColumn('group_title', array(
- 'header' => Mage::helper('core')->__('Store Name'),
- 'align' =>'left',
- 'index' => 'group_title',
- 'filter_index' => 'group_table.name',
- 'renderer' => 'adminhtml/system_store_grid_render_group'
- ));
-
- $this->addColumn('store_title', array(
- 'header' => Mage::helper('core')->__('Store View Name'),
- 'align' =>'left',
- 'index' => 'store_title',
- 'filter_index' => 'store_table.name',
- 'renderer' => 'adminhtml/system_store_grid_render_store'
- ));
-
- return parent::_prepareColumns();
- }
-
-}
View
47 app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Group.php
@@ -1,47 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-/**
- * Store render group
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @author Magento Core Team <core@magentocommerce.com>
- */
-
-class Mage_Adminhtml_Block_System_Store_Grid_Render_Group
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
-{
- public function render(Varien_Object $row)
- {
- if (!$row->getData($this->getColumn()->getIndex())) {
- return null;
- }
- return '<a title="' . Mage::helper('core')->__('Edit Store') . '"
- href="' . $this->getUrl('*/*/editGroup', array('group_id' => $row->getGroupId())) . '">'
- . $this->escapeHtml($row->getData($this->getColumn()->getIndex())) . '</a>';
- }
-}
View
47 app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Store.php
@@ -1,47 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-/**
- * Store render store
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @author Magento Core Team <core@magentocommerce.com>
- */
-
-class Mage_Adminhtml_Block_System_Store_Grid_Render_Store
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
-{
- public function render(Varien_Object $row)
- {
- if (!$row->getData($this->getColumn()->getIndex())) {
- return null;
- }
- return '<a title="' . Mage::helper('core')->__('Edit Store View') . '"
- href="' . $this->getUrl('*/*/editStore', array('store_id' => $row->getStoreId())) . '">'
- . $this->escapeHtml($row->getData($this->getColumn()->getIndex())) . '</a>';
- }
-}
View
46 app/code/core/Mage/Adminhtml/Block/System/Store/Grid/Render/Website.php
@@ -1,46 +0,0 @@
-<?php
-/**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Magento to newer
- * versions in the future. If you wish to customize Magento for your
- * needs please refer to http://www.magentocommerce.com for more information.
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
-
-/**
- * Store render website
- *
- * @category Mage
- * @package Mage_Adminhtml
- * @author Magento Core Team <core@magentocommerce.com>
- */
-
-class Mage_Adminhtml_Block_System_Store_Grid_Render_Website
- extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
-{
-
- public function render(Varien_Object $row)
- {
- return '<a title="' . Mage::helper('core')->__('Edit Website') . '"
- href="' . $this->getUrl('*/*/editWebsite', array('website_id' => $row->getWebsiteId())) . '">'
- . $this->escapeHtml($row->getData($this->getColumn()->getIndex())) . '</a>';
- }
-
-}
View
23 app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
@@ -32,20 +32,30 @@
* @author Magento Core Team <core@magentocommerce.com>
*/
-class Mage_Adminhtml_Block_System_Store_Store extends Mage_Adminhtml_Block_Widget_Grid_Container
+class Mage_Adminhtml_Block_System_Store_Store extends Mage_Adminhtml_Block_Widget_Container
{
public function __construct()
{
$this->_controller = 'system_store';
$this->_headerText = Mage::helper('adminhtml')->__('Manage Stores');
+ $this->setTemplate('system/store/container.phtml');
parent::__construct();
}
protected function _prepareLayout()
{
- /* Update default add button to add website button */
- $this->_updateButton('add', 'label', Mage::helper('core')->__('Create Website'));
- $this->_updateButton('add', 'onclick', "setLocation('".$this->getUrl('*/*/newWebsite')."')");
+ /* Add website button */
+ $this->_addButton('add', array(
+ 'label' => Mage::helper('core')->__('Create Website'),
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/newWebsite') .'\')',
+ 'class' => 'add',
+ ));
+
+ $this->_addButton('add_group', array(
+ 'label' => Mage::helper('core')->__('Create Store'),
+ 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/newGroup') .'\')',
+ 'class' => 'add',
+ ));
/* Add Store Group button */
$this->_addButton('add_group', array(
@@ -64,6 +74,11 @@ protected function _prepareLayout()
return parent::_prepareLayout();
}
+ public function getGridHtml()
+ {
+ return $this->getLayout()->createBlock('adminhtml/system_store_tree')->toHtml();
+ }
+
public function getAddNewButtonHtml()
{
return join(' ', array(
View
162 app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php
@@ -0,0 +1,162 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Open Software License (OSL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/osl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+ */
+
+
+/**
+ * Adminhtml store tree
+ *
+ * @category Mage
+ * @package Mage_Adminhtml
+ * @author Magento Core Team <core@magentocommerce.com>
+ */
+class Mage_Adminhtml_Block_System_Store_Tree extends Mage_Adminhtml_Block_Widget
+{
+
+ /**
+ * Constructor
+ */
+ public function _construct()
+ {
+ $this->setTemplate('system/store/tree.phtml');
+ parent::_construct();
+ }
+
+ /**
+ * Get table data
+ *
+ * @return array
+ */
+ public function getTableData()
+ {
+ $data = array();
+ foreach (Mage::getModel('core/website')->getCollection() as $website) { /* @var $website Mage_Core_Model_Website */
+ $data[$website->getId()] = array(
+ '_object' => $website,
+ '_storeGroups' => array()
+ );
+ foreach ($website->getGroupCollection() as $storeGroup) { /* @var $storeGroup Mage_Core_Model_Store_Group */
+ $data[$website->getId()]['_storeGroups'][$storeGroup->getId()] = array(
+ '_object' => $storeGroup,
+ '_stores' => array()
+ );
+ foreach ($storeGroup->getStoreCollection() as $store) { /* @var $store Mage_Core_Model_Store */
+ $data[$website->getId()]['_storeGroups'][$storeGroup->getId()]['_stores'][$store->getId()] = array(
+ '_object' => $store
+ );
+ }
+ }
+ }
+
+ // set default store groups and stores
+ foreach ($data as $websiteId => $webSiteData) {
+ $website = $webSiteData['_object']; /* @var $website Mage_Core_Model_Website */
+
+ $defaultGroupId = $website->getDefaultGroupId();
+
+ if ($defaultGroupId) {
+ $defaultStoreGroup = $data[$websiteId]['_storeGroups'][$defaultGroupId]['_object']; /* @var $defaultStoreGroup Mage_Core_Model_Store_Group */
+ $defaultStoreGroup->setData('is_default_in_website', true);
+ }
+
+ foreach ($data[$websiteId]['_storeGroups'] as $storeGroupId => $storeGroupData) {
+ $storeGroup = $storeGroupData['_object']; /* @var $storeGroup Mage_Core_Model_Store_Group */
+ $defaultStoreId = $storeGroup->getDefaultStoreId();
+ if ($defaultStoreId) {
+ $defaultStore = $data[$websiteId]['_storeGroups'][$storeGroupId]['_stores'][$defaultStoreId]['_object']; /* @var $defaultStore Mage_Core_Model_Store */
+ $defaultStore->setData('is_default_in_storegroup', true);
+ }
+ }
+ }
+
+ // update counts
+ foreach ($data as $websiteId => $webSiteData) {
+ $data[$websiteId]['_count'] = 0;
+ foreach ($data[$websiteId]['_storeGroups'] as $storeGroupId => $storeGroupData) {
+ $storeGroupCount = max(1, count($data[$websiteId]['_storeGroups'][$storeGroupId]['_stores']));
+ $data[$websiteId]['_storeGroups'][$storeGroupId]['_count'] = $storeGroupCount;
+ $data[$websiteId]['_count'] += $storeGroupCount;
+ }
+ $data[$websiteId]['_count'] = max(1, $data[$websiteId]['_count']);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Render website cell
+ *
+ * @param Mage_Core_Model_Website $website
+ * @return string
+ */
+ public function renderWebsiteCell(Mage_Core_Model_Website $website)
+ {
+ $result = '<a title="Id: ' . $website->getId() . '" href="' . $this->getUrl('*/*/editWebsite', array('website_id' => $website->getWebsiteId())) . '">' . $website->getName() . '</a>';
+ if ($website->getIsDefault()) {
+ $result = '<strong>' . $result . '</strong>';
+ }
+ $result .= ' <br /><span class="additional-info">(' . $this->__('ID') . ': ' . $website->getId() . ' / ' . $this->__('Code') . ': ' . $website->getCode() . ')</span>';
+ return $result;
+ }
+
+ /**
+ * Render store group cell
+ *
+ * @param Mage_Core_Model_Store_Group $storeGroup
+ * @return string
+ */
+ public function renderStoreGroupCell(Mage_Core_Model_Store_Group $storeGroup)
+ {
+ $result = '<a title="Id: ' . $storeGroup->getId() . '" href="' . $this->getUrl('*/*/editGroup', array('group_id' => $storeGroup->getGroupId())) . '">' . $storeGroup->getName() . '</a>';
+ if ($storeGroup->getData('is_default_in_website')) {
+ $result = '<strong>' . $result . '</strong>';
+ }
+
+ $rootCategory = Mage::getModel('catalog/category')->load($storeGroup->getRootCategoryId());
+
+ $result .= ' <br /><span class="additional-info">(' . $this->__('ID') . ': ' . $storeGroup->getId() . ' / ' . $this->__('Root Category') . ': ' . $rootCategory->getName() . ')</span>';
+ return $result;
+ }
+
+ /**
+ * Render store cell
+ *
+ * @param Mage_Core_Model_Store $store
+ * @return string
+ */
+ public function renderStoreCell(Mage_Core_Model_Store $store)
+ {
+ $result = '<a title="Id: ' . $store->getId() . '" href="' . $this->getUrl('*/*/editStore', array('store_id' => $store->getStoreId())) . '">' . $store->getName() . '</a>';
+ if (!$store->getIsActive()) {
+ $result = '<strike>' . $result . '</strike>';
+ }
+ if ($store->getData('is_default_in_storegroup')) {
+ $result = '<strong>' . $result . '</strong>';
+ }
+ $result .= ' <br /><span class="additional-info">(' . $this->__('ID') . ': ' . $store->getId() . ' / ' . $this->__('Code') . ': ' . $store->getCode() . ')</span>';
+ return $result;
+ }
+
+}
View
37 app/design/adminhtml/default/default/template/system/store/container.phtml
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category design
+ * @package default_default
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+?>
+<div class="content-header">
+ <table cellspacing="0">
+ <tr>
+ <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
+ <td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
+ </tr>
+ </table>
+</div>
+<div>
+ <?php echo $this->getGridHtml() ?>
+</div>
View
77 app/design/adminhtml/default/default/template/system/store/tree.phtml
@@ -0,0 +1,77 @@
+<?php /* @var $this Mage_Adminhtml_Block_System_Store_Tree */ ?>
+
+<style type="text/css">
+ span.additional-info { color: #aaa; font-size: smaller; }
+ span.not-available { color: #aaa; font-style: italic; }
+</style>
+
+<div class="grid">
+ <table class="data" cellspacing="0">
+ <thead>
+ <tr class="headings">
+ <th class="no-link"><span class="nobr"><a href="<?php echo $this->getUrl('*/*/newWebsite') ?>"><?php echo Mage::helper('core')->__('Website Name') ?></a></span></th>
+ <th class="no-link"><span class="nobr"><a href="<?php echo $this->getUrl('*/*/newGroup') ?>"><?php echo Mage::helper('core')->__('Store Name') ?></a></span></th>
+ <th class="no-link"><span class="nobr"><a href="<?php echo $this->getUrl('*/*/newStore') ?>"><?php echo Mage::helper('core')->__('Store View Name') ?></a></span></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php $i = 0;?>
+ <?php $printedWebsite = $printedStoreGroup = false; ?>
+ <?php foreach ($this->getTableData() as $webSiteId => $webSiteData): ?>
+
+ <?php if (count($webSiteData['_storeGroups']) == 0): ?>
+
+ <tr>
+ <?php if (!$printedWebsite): ?>
+ <td class="a-left" rowspan="<?php echo $webSiteData['_count'] ?>"><?php echo $this->renderWebsiteCell($webSiteData['_object']) ?></td>
+ <?php $printedWebsite = true; ?>
+ <?php endif ?>
+
+ <td colspan="2" class="a-left last"><span class="not-available"><?php echo $this->__('No store groups and stores available') ?></span></td>
+ </tr>
+
+ <?php else: ?>
+
+ <?php foreach ($webSiteData['_storeGroups'] as $storeGroupId => $storeGroupData): ?>
+ <?php if (count($storeGroupData['_stores']) == 0): ?>
+ <tr>
+ <?php if (!$printedWebsite): ?>
+ <td class="a-left" rowspan="<?php echo $webSiteData['_count'] ?>"><?php echo $this->renderWebsiteCell($webSiteData['_object']) ?></td>
+ <?php $printedWebsite = true; ?>
+ <?php endif ?>
+
+ <?php if (!$printedStoreGroup): ?>
+ <td class="a-left" rowspan="<?php echo $storeGroupData['_count'] ?>"><?php echo $this->renderStoreGroupCell($storeGroupData['_object']) ?></td>
+ <?php $printedStoreGroup = true; ?>
+ <?php endif ?>
+
+ <td class="a-left last"><span class="not-available"><?php echo $this->__('No stores available') ?></span></td>
+ </tr>
+ <?php else: ?>
+
+ <?php foreach ($storeGroupData['_stores'] as $storeId => $storeData): ?>
+ <tr>
+ <?php if (!$printedWebsite): ?>
+ <td class="a-left" rowspan="<?php echo $webSiteData['_count'] ?>"><?php echo $this->renderWebsiteCell($webSiteData['_object']) ?></td>
+ <?php $printedWebsite = true; ?>
+ <?php endif ?>
+
+ <?php if (!$printedStoreGroup): ?>
+ <td class="a-left" rowspan="<?php echo $storeGroupData['_count'] ?>"><?php echo $this->renderStoreGroupCell($storeGroupData['_object']) ?></td>
+ <?php $printedStoreGroup = true; ?>
+ <?php endif ?>
+
+ <td class="a-left last"><?php echo $this->renderStoreCell($storeData['_object']); ?></td>
+ </tr>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ <?php $printedStoreGroup = false; ?>
+ <?php endforeach; ?>
+
+ <?php endif; ?>
+
+ <?php $printedWebsite = false; ?>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+</div>
Something went wrong with that request. Please try again.