Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds configurable columns to product grid #3451

Draft
wants to merge 108 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
940c985
WIP
empiricompany Aug 18, 2023
15ab51b
add to category product
empiricompany Aug 18, 2023
462f182
add to related upsell crossell
empiricompany Aug 18, 2023
4743493
set fixed width
empiricompany Aug 18, 2023
73398a4
clean
empiricompany Aug 19, 2023
f74e4ee
clean
empiricompany Aug 19, 2023
716310f
cosmetic
empiricompany Aug 19, 2023
41fbdd3
css parent
empiricompany Aug 19, 2023
480763b
doc
empiricompany Aug 19, 2023
3d96895
refactor
empiricompany Aug 19, 2023
b2c0b18
default width 64
empiricompany Aug 19, 2023
852bcbd
phpcs phpstan
empiricompany Aug 19, 2023
5b4f58e
Merge branch 'OpenMage:main' into gridproductimage
empiricompany Aug 19, 2023
43262da
phpcsfixer
empiricompany Aug 19, 2023
abd8a07
phpcs
empiricompany Aug 19, 2023
be9d683
add configuration
empiricompany Aug 19, 2023
b1732aa
support all columns configuration
empiricompany Aug 20, 2023
3a337e6
fix issues in catalog category
empiricompany Aug 20, 2023
ab02a33
add configuration enable grids
empiricompany Aug 20, 2023
e421c71
fix select option filters
empiricompany Aug 20, 2023
fba16e6
mistype
empiricompany Aug 20, 2023
97b84f4
indentation
empiricompany Aug 20, 2023
fa624dc
support create_at updated_at column
empiricompany Aug 21, 2023
deaf110
add horizontal scroll to top
empiricompany Aug 21, 2023
9fded51
Merge branch 'main' into gridproductimage
fballiano Aug 21, 2023
fd72106
configuration foreach grid area
empiricompany Aug 24, 2023
6d98ed1
phpstan
empiricompany Aug 24, 2023
00456a5
refactor simplify trait
empiricompany Aug 24, 2023
2156ffc
improve configuration
empiricompany Aug 24, 2023
87e625f
naming convention
empiricompany Aug 24, 2023
d187131
phpcs
empiricompany Aug 24, 2023
709bb7e
renaming methods
empiricompany Aug 24, 2023
e29ff21
fix doc
empiricompany Aug 24, 2023
9334643
phpcs
empiricompany Aug 24, 2023
e41b0ba
phpcs
empiricompany Aug 24, 2023
cabef76
phpstan
empiricompany Aug 24, 2023
2391f61
WIP add order column by drag&drop
empiricompany Aug 29, 2023
e9774e2
WIP columns reorder
empiricompany Aug 29, 2023
2aaaef6
Update app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config.php
empiricompany Aug 29, 2023
b543f30
Update app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/C…
empiricompany Aug 29, 2023
47a4879
Update app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config.php
empiricompany Aug 29, 2023
ce5dd89
some stylish
empiricompany Aug 29, 2023
89cc900
WIP
empiricompany Aug 29, 2023
3f8f563
WIP better javascript
empiricompany Aug 30, 2023
ef389e4
WIP refactoring magento way
empiricompany Aug 31, 2023
1aab278
Update app/code/core/Mage/Adminhtml/Block/Widget/Grid/Config/Product/…
empiricompany Aug 31, 2023
aa6ad04
fix order new config super product
empiricompany Aug 31, 2023
c564b6a
remove trait
empiricompany Aug 31, 2023
6d11513
fix docblock
empiricompany Sep 5, 2023
10286e0
rename system configs
empiricompany Sep 5, 2023
bd37ac2
phpcs
empiricompany Sep 5, 2023
1f058f1
phpcs
empiricompany Sep 5, 2023
c75534b
phpstan
empiricompany Sep 5, 2023
b19823b
add grid controller
empiricompany Sep 6, 2023
9271c31
phpcs
empiricompany Sep 6, 2023
1b2b61f
phpcs
empiricompany Sep 6, 2023
4eb851c
new init helper advanced fix filter order
empiricompany Sep 6, 2023
0c9aced
change system config labels
empiricompany Sep 11, 2023
7181fb4
change system config label to enabled
empiricompany Sep 13, 2023
b3c6ea1
Merge branch 'main' into gridproductimage
fballiano Sep 13, 2023
250aeb8
cannot remove the ending comments, starting comments are still there.…
fballiano Sep 14, 2023
92aea28
css in external file, fixed symbol too
fballiano Sep 14, 2023
6ac0270
removed comments
fballiano Sep 14, 2023
d80bf80
fixed whitespace and license
fballiano Sep 14, 2023
f20ce3f
Added strings to locale CSV
fballiano Sep 14, 2023
63751b9
Fixed some label/comment translations
fballiano Sep 14, 2023
47f681e
Added strings to locale CSV
fballiano Sep 14, 2023
b9757fa
add controls to column sorting
empiricompany Sep 16, 2023
eef88a4
phpcs
empiricompany Sep 16, 2023
85dd828
add confirm reset columns order
empiricompany Sep 16, 2023
92a4986
phpcs
empiricompany Sep 16, 2023
d60da5d
Merge branch 'main' into gridproductimage
empiricompany Sep 16, 2023
00fed97
fix css
empiricompany Sep 16, 2023
67f88e3
fix multigrid column sorting
empiricompany Sep 17, 2023
d09daa1
better style drag icon
empiricompany Sep 17, 2023
7f2904e
refactor better double-scroll
empiricompany Sep 17, 2023
99c34b3
copyright
empiricompany Sep 17, 2023
489bdc0
bettere grid double-scroll handling
empiricompany Sep 17, 2023
0884ef3
fix scrollbar top height in legacy theme
empiricompany Sep 17, 2023
5c0b21e
draggable css fix icon sorting
empiricompany Sep 17, 2023
bd1fcdf
fix add remove events
empiricompany Sep 17, 2023
2b0ce61
cosmetic
empiricompany Sep 17, 2023
3a4ab13
Renamed a couple of things
fballiano Sep 17, 2023
a48c1e6
Fixed todo with uksort
fballiano Sep 17, 2023
699584a
Column indicator moved above the colum for better readability
fballiano Sep 17, 2023
4bae58f
phpcs
fballiano Sep 17, 2023
3da6df6
use class no-display
empiricompany Sep 18, 2023
91b8203
Merge branch 'main' into gridproductimage
fballiano Sep 18, 2023
974b792
fix multi-grid reset button handler
empiricompany Sep 18, 2023
ee89864
Merge branch 'main' into gridproductimage
fballiano Sep 18, 2023
854e4d2
Removed margin and switched arrow style
fballiano Sep 18, 2023
06d34ef
resetted is a typo, but anyway this small message is now already tran…
fballiano Sep 18, 2023
3a7a494
mega basic ACL check
fballiano Sep 18, 2023
006da27
not necessary anymore
fballiano Sep 18, 2023
4294ed3
Added configuration to enable rearrangement
fballiano Sep 20, 2023
9d19518
Merge branch 'main' into gridproductimage
fballiano Sep 20, 2023
9f3dbd6
Implemented ACL
fballiano Sep 20, 2023
6d09657
rename acl title to admin grids
empiricompany Sep 21, 2023
4aefaed
remove conditionally load doublescroll
empiricompany Sep 21, 2023
2335b5d
Merge branch 'main' into gridproductimage
empiricompany Dec 8, 2023
e459ab6
Merge branch 'main' into gridproductimage
fballiano Feb 28, 2024
ea049ba
Merge branch 'main' into gridproductimage
empiricompany Mar 6, 2024
90df199
Merge branch 'main' into gridproductimage
empiricompany Mar 11, 2024
9c3b76c
Merge branch 'main' into gridproductimage
empiricompany Apr 2, 2024
3792f8f
Merge branch 'main' into gridproductimage
empiricompany Apr 10, 2024
dfae985
Merge branch 'main' into gridproductimage
empiricompany Aug 1, 2024
c69ddb2
Merge branch 'main' into gridproductimage
empiricompany Aug 8, 2024
07afcb9
Merge branch 'main' into gridproductimage
sreichel Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ protected function _prepareCollection()
'category_id=' . (int) $this->getRequest()->getParam('id', 0),
'left'
);

$this->setCollection($collection);

if ($this->getCategory()->getProductsReadonly()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ protected function _prepareColumns()
'width' => 60,
'index' => 'entity_id'
]);

$this->addColumn('name', [
'header' => Mage::helper('catalog')->__('Name'),
'index' => 'name'
Expand Down
2 changes: 2 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function _prepareCollection()
'left'
);
}

if ($store->getId()) {
//$collection->setStoreId($store->getId());
$adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
Expand Down Expand Up @@ -151,6 +152,7 @@ protected function _prepareColumns()
'index' => 'entity_id',
]
);

$this->addColumn(
'name',
[
Expand Down
218 changes: 217 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
*/
protected $_massactionBlockName = 'adminhtml/widget_grid_massaction';

/**
* Advanced Grid block name
*
* @var string
*/
protected $_advancedGridBlockName = 'adminhtml/widget_grid_advanced';

/**
* Advanced Grid helper name
*
* @var string
*/
protected $_advancedGridHelperName = 'adminhtml/widget_grid_config';

/**
* Advanced Grid helper
*
*/
protected $_advancedGridHelper = null;

/**
* RSS list
*
Expand Down Expand Up @@ -274,6 +294,22 @@ public function getExportButtonHtml()
return $this->getChildHtml('export_button');
}

/**
* @return string
*/
public function getResetColumnsButtonHtml()
{
return $this->getChildHtml('reset_columns_order_button');
}

/**
* @return string
*/
public function getToggleColumnsOrderButtonHtml()
{
return $this->getChildHtml('toggle_columns_order_button');
}

/**
* @return string
*/
Expand All @@ -296,6 +332,10 @@ public function getSearchButtonHtml()
public function getMainButtonsHtml()
{
$html = '';
if ($this->getAdvancedGridHelper()->isEnabled()) {
$html .= $this->getToggleColumnsOrderButtonHtml();
$html .= $this->getResetColumnsButtonHtml();
}
if ($this->getFilterVisibility()) {
$html .= $this->getResetFilterButtonHtml();
$html .= $this->getSearchButtonHtml();
Expand Down Expand Up @@ -566,6 +606,7 @@ protected function _setCollectionOrder($column)
protected function _prepareCollection()
{
if ($this->getCollection()) {
$this->_prepareAdvancedGrid();
$this->_preparePage();

$columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
Expand Down Expand Up @@ -622,13 +663,125 @@ protected function _preparePage()
}

/**
* Prepeare columns for grid
* Prepare columns for grid
*
* @return $this
*/
protected function _prepareColumns()
{
$this->sortColumnsByOrder();
$this->_prepareAdvancedGridColumn();
return $this;
}

/**
* Prepare grid advanced grid block
*
* @return $this
*/
protected function _prepareAdvancedGridBlock()
{
$this->setChild('advanced_grid', $this->getLayout()->createBlock($this->getAdvancedGridBlockName()));

$helper = $this->getAdvancedGridHelper();
if ($helper->isEnabled() && $helper->isRearrangeEnabled()) {
$this->setChild(
'toggle_columns_order_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'class' => 'toggle_columns_order_button',
'label' => Mage::helper('adminhtml')->__('Rearrange Columns'),
])
);
$this->setChild(
'reset_columns_order_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('adminhtml')->__('Reset Columns Order'),
'class' => 'reset_columns_order_button delete',
])
);
}
return $this;
}

/**
* Get Helper Advanced Grid
*
* @return Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract
*/
public function getAdvancedGridHelper(): Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract
{
if (!$this->_advancedGridHelper) {
// TODO create factory class map block id to helper - create a new grid.xml configuration file
switch ($this->getId()) {
case 'productGrid':
case 'catalog_category_products':
case 'related_product_grid':
case 'up_sell_product_grid':
case 'cross_sell_product_grid':
case 'super_product_links':
$this->setAdvancedGridHelperName('adminhtml/widget_grid_config_catalog_product');
break;
}
$this->_advancedGridHelper = Mage::helper($this->getAdvancedGridHelperName());

if (!($this->_advancedGridHelper instanceof Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract)) {
Mage::throwException(
$this->__("Helper for advanced grid config doesn't implement required interface. %s must extends Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract", get_class($this->_advancedGridHelper))
);
}
}
$this->_advancedGridHelper->setGridId($this->getId());
return $this->_advancedGridHelper;
}

/**
* Prepare advanced grid collection
*
* @return $this
*/
protected function _prepareAdvancedGrid()
{
if (!$this->getAdvancedGridHelper()->isEnabled()) {
return $this;
}
$this->getAdvancedGridHelper()->applyAdvancedGridCollection($this->getCollection());
return $this;
}

/**
* Prepare advanced grid column
*
* @return $this
*/
protected function _prepareAdvancedGridColumn()
{
if (!$this->getAdvancedGridHelper()->isEnabled()) {
return $this;
}
//if ($helper instanceof CollectionStrategyInterface) {
$this->getAdvancedGridHelper()->applyAdvancedGridColumn($this);
// customize order column
$_orderColumns = $this->getAdvancedGridHelper()->getOrderColumns();
if ($_orderColumns) {
// Reset Column Order
$this->_columnsOrder = [];
uksort($this->_columns, function ($a, $b) use ($_orderColumns) {
$posA = array_search($a, $_orderColumns);
$posB = array_search($b, $_orderColumns);
if ($posA > $posB) {
return 1;
}
if ($posA < $posB) {
return -1;
}
return 0;
});
} else {
$this->sortColumnsByOrder();
}

return $this;
}

Expand Down Expand Up @@ -699,6 +852,7 @@ protected function _prepareGrid()
$this->_prepareColumns();
$this->_prepareMassactionBlock();
$this->_prepareCollection();
$this->_prepareAdvancedGridBlock();
return $this;
}

Expand Down Expand Up @@ -1581,6 +1735,68 @@ public function getMassactionBlockHtml()
return $this->getChildHtml('massaction');
}

/**
* Retrieve advanced grid block name
*
* @return string
*/
public function getAdvancedGridBlockName()
{
return $this->_advancedGridBlockName;
}

/**
* Set advanced grid block name
*
* @param string $blockName
* @return $this
*/
public function setAdvancedGridBlockName($blockName)
{
$this->_advancedGridBlockName = $blockName;
return $this;
}

/**
* Retrieve advanced grid helper name
*
* @return string
*/
public function getAdvancedGridHelperName()
{
return $this->_advancedGridHelperName;
}

/**
* Set advanced grid helper name
*
* @param string $helperName
* @return $this
*/
public function setAdvancedGridHelperName($helperName)
{
$this->_advancedGridHelperName = $helperName;
return $this;
}

/**
* Retrieve advanced grid block
*
* @return Mage_Adminhtml_Block_Widget_Grid_Advanced_Abstract
*/
public function getAdvancedGridBlock()
{
return $this->getChild('advanced_grid');
}

/**
* @return string
*/
public function getAdvancedGridBlockHtml()
{
return $this->getChildHtml('advanced_grid');
}

/**
* Set empty text for grid
*
Expand Down
24 changes: 24 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid/Advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* OpenMage
*
* 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 at https://opensource.org/license/osl-3-0-php
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Grid widget advanced grid default block
*
* @category Mage
* @package Mage_Adminhtml
*/
class Mage_Adminhtml_Block_Widget_Grid_Advanced extends Mage_Adminhtml_Block_Widget_Grid_Advanced_Abstract
{
}
Loading
Loading