Skip to content

Commit

Permalink
[bug-OpenMage#897] Category sort doesn't use system config when defau…
Browse files Browse the repository at this point in the history
…lt_sort_by is not available
  • Loading branch information
midlan authored and edannenberg committed Aug 20, 2020
1 parent 0be31a8 commit 7a973d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/code/core/Mage/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,17 @@ public function getAvailableSortByOptions() {
* @return string
*/
public function getDefaultSortBy() {
if (!$sortBy = $this->getData('default_sort_by')) {
$sortBy = $this->getData('default_sort_by');
$available = $this->getAvailableSortByOptions();

// When not set or not available use default from system config
if (!$sortBy || !isset($available[$sortBy])) {
$sortBy = Mage::getSingleton('catalog/config')
->getProductListDefaultSortBy($this->getStoreId());
}
$available = $this->getAvailableSortByOptions();
if (!isset($available[$sortBy])) {

// If even the sort from system config not set or unavailable, use the first of available
if (!$sortBy || !isset($available[$sortBy])) {
$sortBy = array_keys($available);
$sortBy = $sortBy[0];
}
Expand Down

0 comments on commit 7a973d4

Please sign in to comment.