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

Fixed sort in Manage Tax Rates grid #2757

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
30 changes: 0 additions & 30 deletions .github/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,11 @@ parameters:
count: 1
path: ../app/code/core/Mage/Adminhtml/Block/Permissions/Grid/User.php

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#"
count: 2
path: ../app/code/core/Mage/Adminhtml/Block/Permissions/Role/Grid/User.php

-
message: "#^Call to an undefined method Mage_Admin_Model_Resource_Roles_User_Collection\\:\\:setUserFilter\\(\\)\\.$#"
count: 1
path: ../app/code/core/Mage/Adminhtml/Block/Permissions/Tab/Userroles.php

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#"
count: 2
path: ../app/code/core/Mage/Adminhtml/Block/Permissions/User/Edit/Tab/Roles.php

-
message: "#^Call to method getCollection\\(\\) on an unknown class Mage_Permissions_Model_Roles\\.$#"
count: 1
Expand Down Expand Up @@ -245,11 +235,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

-
message: "#^Method Mage_Adminhtml_Block_Report_Grid_Abstract\\:\\:getCollection\\(\\) should return Mage_Reports_Model_Grouped_Collection but returns Varien_Data_Collection\\.$#"
count: 1
path: ../app/code/core/Mage/Adminhtml/Block/Report/Grid/Abstract.php

-
message: "#^Call to an undefined method Mage_Eav_Model_Entity_Abstract\\:\\:setStore\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -560,16 +545,6 @@ parameters:
count: 2
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Form.php

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#"
count: 2
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:getSelect\\(\\)\\.$#"
count: 3
path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid.php

-
message: "#^Method Mage_Adminhtml_Block_Widget_Grid\\:\\:getSubTotalItem\\(\\) should return Varien_Object but returns string\\.$#"
count: 1
Expand Down Expand Up @@ -1015,11 +990,6 @@ parameters:
count: 1
path: ../app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Tab/Resource.php

-
message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#"
count: 2
path: ../app/code/core/Mage/Api2/Block/Adminhtml/Permissions/User/Edit/Tab/Roles.php

-
message: "#^Property Mage_Api2_Block_Adminhtml_Roles_Tab_Resources\\:\\:\\$_treeModel \\(Mage_Api2_Model_Acl_Global_Rule_Tree\\) does not accept default value of type false\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getResourceCollectionName()
}

/**
* @return Mage_Reports_Model_Grouped_Collection
* @return Mage_Core_Model_Resource_Db_Collection_Abstract|Mage_Reports_Model_Grouped_Collection
*/
public function getCollection()
{
Expand Down
18 changes: 18 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Tax/Rate/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ protected function _prepareCollection()
return parent::_prepareCollection();
}

protected function _setCollectionOrder($column)
{
$collection = $this->getCollection();
if ($collection) {
$columnIndex = $column->getFilterIndex() ?: $column->getIndex();
$collection->setOrder($columnIndex, strtoupper($column->getDir()));

if ($columnIndex === 'region_table.code') {
$collection->addOrder('code', strtoupper($column->getDir()));
}
}
return $this;
}

protected function _prepareColumns()
{
$this->addColumn('code', [
Expand Down Expand Up @@ -95,6 +109,10 @@ protected function _prepareColumns()
return parent::_prepareColumns();
}

/**
* @param Mage_Tax_Model_Calculation_Rate $row
* @return string
*/
public function getRowUrl($row)
{
return $this->getUrl('*/*/edit', ['rate' => $row->getTaxCalculationRateId()]);
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget
/**
* Collection object
*
* @var Varien_Data_Collection
* @var Mage_Core_Model_Resource_Db_Collection_Abstract|null
*/
protected $_collection = null;

Expand Down Expand Up @@ -313,7 +313,7 @@ public function getMainButtonsHtml()
/**
* set collection object
*
* @param Varien_Data_Collection|Varien_Data_Collection_Db $collection
* @param Mage_Core_Model_Resource_Db_Collection_Abstract $collection
*/
public function setCollection($collection)
{
Expand All @@ -323,7 +323,7 @@ public function setCollection($collection)
/**
* get collection object
*
* @return Varien_Data_Collection|Varien_Data_Collection_Db
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
*/
public function getCollection()
{
Expand Down