diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php index c62487dc770..567f9c21334 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Upsell.php @@ -134,6 +134,7 @@ protected function _prepareColumns() 'width' => 60, 'index' => 'entity_id' ]); + $this->addColumn('name', [ 'header' => Mage::helper('catalog')->__('Name'), 'index' => 'name' diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php index 781ae922d15..edef8c7397d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php @@ -61,6 +61,7 @@ protected function _prepareCollection() 'left' ); } + if ($store->getId()) { //$collection->setStoreId($store->getId()); $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID; @@ -151,6 +152,7 @@ protected function _prepareColumns() 'index' => 'entity_id', ] ); + $this->addColumn( 'name', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index f51c7a42c20..350286898e9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -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 * @@ -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 */ @@ -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(); @@ -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); @@ -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; } @@ -699,6 +852,7 @@ protected function _prepareGrid() $this->_prepareColumns(); $this->_prepareMassactionBlock(); $this->_prepareCollection(); + $this->_prepareAdvancedGridBlock(); return $this; } @@ -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 * diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Advanced.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Advanced.php new file mode 100644 index 00000000000..0263cb3a750 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Advanced.php @@ -0,0 +1,24 @@ +setResetConfirmText(Mage::helper('core')->jsQuoteEscape(Mage::helper('core')->__('Are you sure?'))); + } + + /** + * @return string + */ + public function getHtmlId() + { + return $this->getParentBlock()->getHtmlId() . '_advanced'; + } + + /** + * Retrieve advanced block js object name + * + * @return mixed + */ + public function getJsObjectName(): mixed + { + return $this->getHtmlId() . 'JsObject'; + } + + /** + * Retrieve grid block js object name + * + * @return string + */ + public function getGridJsObjectName(): string + { + return $this->getParentBlock()->getJsObjectName(); + } + + /** + * Retrieve grid id + * + * @return mixed + */ + public function getGridId(): mixed + { + return $this->getParentBlock()->getId(); + } + + /** + * @return string + */ + public function getJavaScript(): string + { + // TODO: would be better to use Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract::isRearrangeEnabled + if (!Mage::getStoreConfig(Mage_Adminhtml_Helper_Widget_Grid_Config_Abstract::CONFIG_PATH_ENABLE_REARRANGE_COLUMNS)) { + return ''; + } + + $_content = sprintf( + "var %s = new varienGridAdvanced('%s', %s, '%s');", + $this->getJsObjectName(), + $this->getGridId(), + $this->getGridJsObjectName(), + $this->getUrl('adminhtml/grid/saveColumnOrder') + ); + $_content .= "{$this->getJsObjectName()}.resetConfirmText = '{$this->getResetConfirmText()}';"; + return $_content; + } + + /** + * Checks are advanced grid available + * + * @return bool + */ + public function isAvailable(): bool + { + return $this->getParentBlock()->getAdvancedGridHelper()->isEnabled(); + } +} diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php index 79697d4dbc0..49041679869 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php @@ -294,6 +294,9 @@ protected function _getRendererByType() case 'theme': $rendererClass = 'adminhtml/widget_grid_column_renderer_theme'; break; + case 'productimage': + $rendererClass = 'adminhtml/widget_grid_column_renderer_productimage'; + break; default: $rendererClass = 'adminhtml/widget_grid_column_renderer_text'; break; diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Productimage.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Productimage.php new file mode 100644 index 00000000000..d7af55e5ed7 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Productimage.php @@ -0,0 +1,105 @@ +_checkImageIsSelected($row); + if (!$image) { + return ''; + } + $imageDimensions = $this->getColumn()->getWidth() ?: $this->_defaultWidth; + $imageSrc = $this->_getHelperImage($image)->resize($imageDimensions, $imageDimensions); + $imageUrl = $this->_getImageUrl($image); + $result = ''; + $result .= ''; + $result .= ''; + $result .= ''; + return $result; + } + + /** + * Render column for export + * + * @param Varien_Object $row + * @return string + */ + public function renderExport(Varien_Object $row): string + { + $image = $this->_checkImageIsSelected($row); + if (!$image) { + return ''; + } + return $this->_getImageUrl($image); + } + + /** + * @return string|null + */ + public function renderCss() + { + return parent::renderCss() . ' a-center'; + } + + /** + * @param string $image + * @return Mage_Catalog_Helper_Image + */ + protected function _getHelperImage($image): Mage_Catalog_Helper_Image + { + $dummyProduct = Mage::getModel('catalog/product'); + return Mage::helper('catalog/image')->init($dummyProduct, $this->getColumn()->getAttributeCode(), $image); + } + + /** + * @param string $image + * @return string + */ + protected function _getImageUrl($image): string + { + if (!$image) { + return ''; + } + return Mage::getBaseUrl('media') . 'catalog/product/' . $image; + } + + /** + * @param Varien_Object $row + * @return string|false + */ + private function _checkImageIsSelected($row) + { + $value = $this->_getValue($row); + if (!$value || $value == 'no_selection') { + return false; + } + return $value; + } +} diff --git a/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config.php b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config.php new file mode 100644 index 00000000000..1010b32b951 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config.php @@ -0,0 +1,45 @@ +_gridId = $id; + return $this; + } + + /** + * Get grid id configuration scope + * + * @return string + */ + public function getGridId(): string + { + return $this->_gridId; + } + + /** + * Get store config for grid id + * + * @return mixed + * @throws Mage_Core_Exception + */ + public function getStoreConfigGridId($configPath) + { + if (!$this->_gridId) { + Mage::throwException(Mage::helper('adminhtml')->__('Grid Id must be set.')); + } + $config = sprintf($configPath, $this->_gridId); + return Mage::getStoreConfig($config); + } + + + public function saveOrderColumns($value) + { + $configPath = sprintf(self::CONFIG_PATH_GRID_ORDER, $this->_gridId); + Mage::getModel('core/config')->saveConfig($configPath, $value); + } + + public function getOrderColumns(): array + { + $data = $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_ORDER); + if (!$data) { + return []; + } + + $data = Mage::helper('core')->jsonDecode($data); + return $data; + } + + /** + * Get grid enabled for custom columns + * + * @return bool + */ + public function isEnabled(): bool + { + return $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_ENABLED) ?: false; + } + + /** + * Get grid enabled for custom columns + * + * @return bool + */ + public function isRearrangeEnabled(): bool + { + return + Mage::getStoreConfigFlag(self::CONFIG_PATH_ENABLE_REARRANGE_COLUMNS) && + Mage::getSingleton('admin/session')->isAllowed(self::ACL_RESOURCE_REARRANGE_COLUMNS); + } + + /** + * Collection object + * @param Varien_Data_Collection_Db $collection + * + * return $this + */ + abstract public function applyAdvancedGridCollection($collection); + + /** + * Adminhtml grid widget block + * @param Mage_Adminhtml_Block_Widget_Grid $gridBlock + * + * return $this + */ + abstract public function applyAdvancedGridColumn($gridBlock); +} diff --git a/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Catalog/Product.php b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Catalog/Product.php new file mode 100644 index 00000000000..68f6a95128d --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Catalog/Product.php @@ -0,0 +1,244 @@ +isEnabled()) { + return $this; + } + + if ($collection) { + foreach ($this->getAttributeColumns() as $attributeCode) { + $collection->addAttributeToSelect($attributeCode); + } + + foreach ($this->getImageColumns() as $attributeCode) { + $collection->addAttributeToSelect($attributeCode); + } + + if ($this->isCreatedAtEnabled()) { + $collection->addAttributeToSelect('created_at'); + } + + if ($this->isUpdatedAtEnabled()) { + $collection->addAttributeToSelect('updated_at'); + } + } + + return $this; + } + + /** + * Adminhtml grid widget block + * @param Mage_Adminhtml_Block_Widget_Grid $gridBlock + * + * return $this + */ + public function applyAdvancedGridColumn($gridBlock) + { + $storeId = (int) $gridBlock->getRequest()->getParam('store', 0); + $_keepDefaultOrder = 'entity_id'; + + foreach ($this->getImageColumns() as $attributeCode) { + /** @var Mage_Eav_Model_Attribute $_attributeEntity */ + $_attributeEntity = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, $attributeCode); + $gridBlock->addColumnAfter( + $attributeCode, + [ + 'header' => Mage::helper('catalog')->__($_attributeEntity->getFrontendLabel()), + 'width' => $this->getProductImageWidth(), + 'type' => 'productimage', + 'index' => $attributeCode, + 'attribute_code' => $attributeCode, + ], + $_keepDefaultOrder + ); + $_keepDefaultOrder = $attributeCode; + } + + if ($this->isCreatedAtEnabled()) { + $gridBlock->addColumnAfter( + 'created_at', + [ + 'header' => Mage::helper('catalog')->__('Created At'), + 'type' => 'datetime', + 'index' => 'created_at', + 'attribute_code' => 'created_at', + ], + $_keepDefaultOrder + ); + $_keepDefaultOrder = 'created_at'; + } + + if ($this->isUpdatedAtEnabled()) { + $gridBlock->addColumnAfter( + 'updated_at', + [ + 'header' => Mage::helper('catalog')->__('Updated At'), + 'type' => 'datetime', + 'index' => 'updated_at', + 'attribute_code' => 'updated_at', + ], + $_keepDefaultOrder + ); + $_keepDefaultOrder = 'updated_at'; + } + + foreach ($this->getAttributeColumns() as $attributeCode) { + /** @var Mage_Eav_Model_Entity_Attribute $_attributeEntity */ + $_attributeEntity = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, $attributeCode); + switch ($_attributeEntity->getFrontendInput()) { + case 'price': + $_currency = Mage::app()->getStore($storeId)->getBaseCurrency()->getCode(); + $gridBlock->addColumnAfter( + $attributeCode, + [ + 'header' => Mage::helper('catalog')->__($_attributeEntity->getFrontendLabel()), + 'type' => 'price', + 'index' => $attributeCode, + 'attribute_code' => $attributeCode, + 'currency_code' => $_currency, + ], + $_keepDefaultOrder + ); + break; + case 'date': + $gridBlock->addColumnAfter( + $attributeCode, + [ + 'header' => Mage::helper('catalog')->__($_attributeEntity->getFrontendLabel()), + 'type' => 'date', + 'index' => $attributeCode, + 'attribute_code' => $attributeCode, + ], + $_keepDefaultOrder + ); + break; + case 'multiselect': + case 'select': + $_options = []; + if ($_attributeEntity->usesSource()) { + /** @var Mage_Eav_Model_Entity_Attribute_Source_Table $_sourceModel */ + $_sourceModel = $_attributeEntity->getSource(); + $_allOptions = $_sourceModel->getAllOptions(false, true); + foreach ($_allOptions as $key => $option) { + $_options[$option['value']] = $option['label']; + } + } + $gridBlock->addColumnAfter( + $attributeCode, + [ + 'header' => Mage::helper('catalog')->__($_attributeEntity->getFrontendLabel()), + /* 'width' => '150px', */ + 'type' => 'options', + 'index' => $attributeCode, + 'options' => $_options, + 'attribute_code' => $attributeCode, + ], + $_keepDefaultOrder + ); + break; + default: + $gridBlock->addColumnAfter( + $attributeCode, + [ + 'header' => Mage::helper('catalog')->__($_attributeEntity->getFrontendLabel()), + 'type' => 'text', + 'index' => $attributeCode, + 'attribute_code' => $attributeCode, + ], + $_keepDefaultOrder + ); + break; + } + $_keepDefaultOrder = $attributeCode; + } + } + + /** + * Get column created_at is enabled + * + * @return bool + */ + public function isCreatedAtEnabled(): bool + { + return $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_CREATED_AT); + } + + /** + * Get column updated_at is enabled + * + * @return bool + */ + public function isUpdatedAtEnabled(): bool + { + return $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_UPDATED_AT); + } + + /** + * Get grid enabled for custom columns + * + * @return array + */ + public function getAttributeColumns(): array + { + if (!$this->getStoreConfigGridId(self::CONFIG_PATH_GRID_COLUMNS)) { + return []; + } + return explode(',', $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_COLUMNS)); + } + + /** + * Get grid enabled for custom columns + * + * @return array + */ + public function getImageColumns(): array + { + if (!$this->getStoreConfigGridId(self::CONFIG_PATH_GRID_COLUMN_IMAGE)) { + return []; + } + return explode(',', $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_COLUMN_IMAGE)); + } + + /** + * Get media product image width + * + * @return string + */ + public function getProductImageWidth(): string + { + return $this->getStoreConfigGridId(self::CONFIG_PATH_GRID_COLUMN_IMAGE_WIDTH); + } +} diff --git a/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Interface.php b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Interface.php new file mode 100644 index 00000000000..d9ede263a8f --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Helper/Widget/Grid/Config/Interface.php @@ -0,0 +1,38 @@ +_attributes)) { + $attrCollection = Mage::getResourceModel('catalog/product_attribute_collection') + ->addVisibleFilter() + ->setFrontendInputTypeFilter($this->_supportedColumnsType) + ->addFieldToFilter('frontend_label', ['notnull' => true]) + ->setOrder('frontend_label', Varien_Data_Collection::SORT_ORDER_ASC); + + $this->_attributes = []; + /** @var Mage_Eav_Model_Attribute $attribute */ + foreach ($attrCollection as $attribute) { + if (!in_array($attribute->getAttributeCode(), $this->_excludeDefaultAttributesCode)) { + $this->_attributes[] = [ + 'label' => $attribute->getFrontendLabel(), + 'value' => $attribute->getAttributeCode(), + ]; + } + } + } + return $this->_attributes; + } +} diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/GridIdList.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/GridIdList.php new file mode 100644 index 00000000000..f3b5ec0f129 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/GridIdList.php @@ -0,0 +1,33 @@ + 'productGrid', 'label' => Mage::helper('adminhtml')->__('Catalog Product')], + ['value' => 'catalog_category_products', 'label' => Mage::helper('adminhtml')->__('Catalog Category Product')], + ['value' => 'related_product_grid', 'label' => Mage::helper('adminhtml')->__('Catalog Product Related')], + ['value' => 'up_sell_product_grid', 'label' => Mage::helper('adminhtml')->__('Catalog Product Up-Sells')], + ['value' => 'cross_sell_product_grid', 'label' => Mage::helper('adminhtml')->__('Catalog Product Cross-Sells')], + ]; + } +} diff --git a/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/MediaImage.php b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/MediaImage.php new file mode 100644 index 00000000000..b2de8dace5a --- /dev/null +++ b/app/code/core/Mage/Adminhtml/Model/System/Config/Source/Grid/Catalog/Product/MediaImage.php @@ -0,0 +1,59 @@ +_attributes)) { + $attrCollection = Mage::getResourceModel('catalog/product_attribute_collection') + ->addVisibleFilter() + ->setFrontendInputTypeFilter($this->_supportedColumnsType) + ->addFieldToFilter('frontend_label', ['notnull' => true]) + ->setOrder('frontend_label', Varien_Data_Collection::SORT_ORDER_ASC); + + $this->_attributes = []; + /** @var Mage_Eav_Model_Attribute $attribute */ + foreach ($attrCollection as $attribute) { + $this->_attributes[] = [ + 'label' => $attribute->getFrontendLabel(), + 'value' => $attribute->getAttributeCode(), + ]; + } + } + return $this->_attributes; + } +} diff --git a/app/code/core/Mage/Adminhtml/controllers/GridController.php b/app/code/core/Mage/Adminhtml/controllers/GridController.php new file mode 100644 index 00000000000..9233c336df2 --- /dev/null +++ b/app/code/core/Mage/Adminhtml/controllers/GridController.php @@ -0,0 +1,57 @@ +getRequest()->getPost('gridId'); + $data = $this->getRequest()->getPost('data'); + $reset = $this->getRequest()->getPost('reset'); + if (!$gridId || (!$data && !$reset)) { + return false; + } + + /** @var Mage_Adminhtml_Helper_Widget_Grid_Config $_advancedGridHelper */ + $_advancedGridHelper = Mage::helper('adminhtml/widget_grid_config'); + $_advancedGridHelper + ->setGridId($gridId) + ->saveOrderColumns($data); + } + + /** + * Check is allowed access to action + * + * @return bool + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed(static::ADMIN_RESOURCE); + } +} diff --git a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml index 3d05467b27c..d4bec256aae 100644 --- a/app/code/core/Mage/Adminhtml/etc/adminhtml.xml +++ b/app/code/core/Mage/Adminhtml/etc/adminhtml.xml @@ -205,6 +205,10 @@