From f8a125c0bf26a5c75a08fa5c5ab02a8cb92cb5be Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 12 May 2023 23:51:03 +0100 Subject: [PATCH 1/9] rebase --- .../Block/Catalog/Category/Tab/Product.php | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index 6adefb61adc..dd6c9df290a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -81,8 +81,14 @@ protected function _prepareCollection() 'position', 'product_id=entity_id', 'category_id=' . (int) $this->getRequest()->getParam('id', 0), - 'left' - ); + 'left'); + $collection->joinAttribute( + 'status', + 'catalog_product/status', + 'entity_id', + null, + 'inner' + ); $this->setCollection($collection); if ($this->getCategory()->getProductsReadonly()) { @@ -142,6 +148,36 @@ protected function _prepareColumns() 'editable' => !$this->getCategory()->getProductsReadonly() //'renderer' => 'adminhtml/widget_grid_column_renderer_input' ]); + $this->addColumn('status', array( + 'header' => Mage::helper('catalog')->__('Status'), + 'width' => '70', + 'index' => 'status', + 'type' => 'options', + 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), + )); + $this->addColumn('action', array( + 'header' => Mage::helper('catalog')->__('Action'), + 'width' => '50px', + 'type' => 'action', + 'getter' => 'getId', + 'actions' => array( + array( + 'caption' => Mage::helper('catalog')->__('Edit'), + 'id' => 'editlink', + 'url' => array( + 'base' => 'adminhtml/catalog_product/edit', + 'params' => array( + 'store' => $this->getRequest()->getParam('store'), + ), + ), + 'field' => 'id', + 'onclick' => 'popWin(this.href,\'_blank\',\'width=1024,height=750,resizable=1,scrollbars=1\');return false;' + ), + ), + 'filter' => false, + 'sortable' => false, + 'index' => 'stores', + )); return parent::_prepareColumns(); } From d3dad48f41eff16ae6cc5e849fbbf9b8bbb495bc Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 12 May 2023 23:56:08 +0100 Subject: [PATCH 2/9] short syntax --- .../Block/Catalog/Category/Tab/Product.php | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index dd6c9df290a..5fb490ac6a1 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -82,13 +82,7 @@ protected function _prepareCollection() 'product_id=entity_id', 'category_id=' . (int) $this->getRequest()->getParam('id', 0), 'left'); - $collection->joinAttribute( - 'status', - 'catalog_product/status', - 'entity_id', - null, - 'inner' - ); + $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner'); $this->setCollection($collection); if ($this->getCategory()->getProductsReadonly()) { @@ -148,36 +142,34 @@ protected function _prepareColumns() 'editable' => !$this->getCategory()->getProductsReadonly() //'renderer' => 'adminhtml/widget_grid_column_renderer_input' ]); - $this->addColumn('status', array( + $this->addColumn('status', [ 'header' => Mage::helper('catalog')->__('Status'), 'width' => '70', 'index' => 'status', 'type' => 'options', 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), - )); - $this->addColumn('action', array( + ]); + $this->addColumn('action', [ 'header' => Mage::helper('catalog')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', - 'actions' => array( - array( + 'actions' => [ + [ 'caption' => Mage::helper('catalog')->__('Edit'), 'id' => 'editlink', - 'url' => array( + 'url' => [ 'base' => 'adminhtml/catalog_product/edit', - 'params' => array( - 'store' => $this->getRequest()->getParam('store'), - ), - ), + 'params' => ['store' => $this->getRequest()->getParam('store')], + ], 'field' => 'id', 'onclick' => 'popWin(this.href,\'_blank\',\'width=1024,height=750,resizable=1,scrollbars=1\');return false;' - ), - ), + ], + ], 'filter' => false, 'sortable' => false, 'index' => 'stores', - )); + ]); return parent::_prepareColumns(); } From 3e88165b2d7204ff60d4047518de0968ce86a5c0 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 12 May 2023 23:59:44 +0100 Subject: [PATCH 3/9] phpcs --- .../core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index 5fb490ac6a1..aa93821b156 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -81,7 +81,8 @@ protected function _prepareCollection() 'position', 'product_id=entity_id', 'category_id=' . (int) $this->getRequest()->getParam('id', 0), - 'left'); + 'left' + ); $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner'); $this->setCollection($collection); From 3114072e3194f9879083c17e09ba5d91e497d8c5 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 13 May 2023 00:08:03 +0100 Subject: [PATCH 4/9] removed the popup window --- .../Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index aa93821b156..364e9607190 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -159,12 +159,12 @@ protected function _prepareColumns() [ 'caption' => Mage::helper('catalog')->__('Edit'), 'id' => 'editlink', + 'field' => 'id', + 'onclick' => 'event.stopPropagation()', 'url' => [ 'base' => 'adminhtml/catalog_product/edit', 'params' => ['store' => $this->getRequest()->getParam('store')], - ], - 'field' => 'id', - 'onclick' => 'popWin(this.href,\'_blank\',\'width=1024,height=750,resizable=1,scrollbars=1\');return false;' + ] ], ], 'filter' => false, From 191f050baf6f4979ba90cc2aeedb70a690cbf854 Mon Sep 17 00:00:00 2001 From: ADDISON <8360474+ADDISON74@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:35:00 +0200 Subject: [PATCH 5/9] Grid columns for Category Products This change makes the Category Products grid having the same columns and format as the Related Products / Up-sells / Cross-sells grids. --- .../Block/Catalog/Category/Tab/Product.php | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index 1edcd46c749..d66f0544135 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -82,8 +82,9 @@ protected function _prepareCollection() 'product_id=entity_id', 'category_id=' . (int) $this->getRequest()->getParam('id', 0), 'left' - ); - $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner'); + ) + ->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner') + ->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner'); $this->setCollection($collection); if ($this->getCategory()->getProductsReadonly()) { @@ -113,28 +114,69 @@ protected function _prepareColumns() 'index' => 'entity_id' ]); } + $this->addColumn('entity_id', [ 'header' => Mage::helper('catalog')->__('ID'), 'sortable' => true, 'width' => '60', 'index' => 'entity_id' ]); + $this->addColumn('name', [ 'header' => Mage::helper('catalog')->__('Name'), 'index' => 'name' ]); + + $this->addColumn('type', [ + 'header' => Mage::helper('catalog')->__('Type'), + 'width' => 100, + 'index' => 'type_id', + 'type' => 'options', + 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(), + ]); + + $sets = Mage::getResourceModel('eav/entity_attribute_set_collection') + ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()) + ->load() + ->toOptionHash(); + + $this->addColumn('set_name', [ + 'header' => Mage::helper('catalog')->__('Attrib. Set Name'), + 'width' => 130, + 'index' => 'attribute_set_id', + 'type' => 'options', + 'options' => $sets, + ]); + + $this->addColumn('status', [ + 'header' => Mage::helper('catalog')->__('Status'), + 'width' => 90, + 'index' => 'status', + 'type' => 'options', + 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), + ]); + + $this->addColumn('visibility', [ + 'header' => Mage::helper('catalog')->__('Visibility'), + 'width' => 90, + 'index' => 'visibility', + 'type' => 'options', + 'options' => Mage::getSingleton('catalog/product_visibility')->getOptionArray(), + ]); + $this->addColumn('sku', [ 'header' => Mage::helper('catalog')->__('SKU'), 'width' => '80', 'index' => 'sku' ]); + $this->addColumn('price', [ 'header' => Mage::helper('catalog')->__('Price'), 'type' => 'currency', - 'width' => '1', 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE), 'index' => 'price' ]); + $this->addColumn('position', [ 'header' => Mage::helper('catalog')->__('Position'), 'width' => '1', @@ -143,13 +185,7 @@ protected function _prepareColumns() 'editable' => !$this->getCategory()->getProductsReadonly() //'renderer' => 'adminhtml/widget_grid_column_renderer_input' ]); - $this->addColumn('status', [ - 'header' => Mage::helper('catalog')->__('Status'), - 'width' => '70', - 'index' => 'status', - 'type' => 'options', - 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(), - ]); + $this->addColumn('action', [ 'header' => Mage::helper('catalog')->__('Action'), 'width' => '50px', From a3e0da3694218539e1a1728fff4269df942b8a82 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 25 Apr 2024 18:50:59 +0100 Subject: [PATCH 6/9] phpcs --- .../core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index d66f0544135..0106a2e1207 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -183,9 +183,8 @@ protected function _prepareColumns() 'type' => 'number', 'index' => 'position', 'editable' => !$this->getCategory()->getProductsReadonly() - //'renderer' => 'adminhtml/widget_grid_column_renderer_input' ]); - + $this->addColumn('action', [ 'header' => Mage::helper('catalog')->__('Action'), 'width' => '50px', From dcafe4ed0a67d71738cc2d9bf995b07c159bea18 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 25 Apr 2024 19:10:29 +0100 Subject: [PATCH 7/9] Restore opening in popup and passing the popup param --- .../Block/Catalog/Category/Tab/Product.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php index 0106a2e1207..bec23bce0a1 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Product.php @@ -192,14 +192,17 @@ protected function _prepareColumns() 'getter' => 'getId', 'actions' => [ [ - 'caption' => Mage::helper('catalog')->__('Edit'), - 'id' => 'editlink', - 'field' => 'id', - 'onclick' => 'event.stopPropagation()', - 'url' => [ - 'base' => 'adminhtml/catalog_product/edit', - 'params' => ['store' => $this->getRequest()->getParam('store')], - ] + 'caption' => Mage::helper('catalog')->__('Edit'), + 'id' => 'editlink', + 'field' => 'id', + 'onclick' => "popWin(this.href,'win','width=1000,height=700,resizable=1,scrollbars=1');return false;", + 'url' => [ + 'base' => 'adminhtml/catalog_product/edit', + 'params' => [ + 'store' => $this->getRequest()->getParam('store'), + 'popup' => 1 + ], + ], ], ], 'filter' => false, From b5b29da6927a98e044e3858a499e77f7732da368 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 25 Apr 2024 19:28:32 +0100 Subject: [PATCH 8/9] avoid js error when closing popup --- .../template/catalog/product/created.phtml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/design/adminhtml/default/default/template/catalog/product/created.phtml b/app/design/adminhtml/default/default/template/catalog/product/created.phtml index f2e86099f3b..90115a3d54b 100644 --- a/app/design/adminhtml/default/default/template/catalog/product/created.phtml +++ b/app/design/adminhtml/default/default/template/catalog/product/created.phtml @@ -16,14 +16,16 @@