File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
app/code/Magento/Catalog/Helper/Product Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class ProductList
29
29
* @var \Magento\Framework\App\Config\ScopeConfigInterface
30
30
*/
31
31
protected $ scopeConfig ;
32
+ protected $ coreRegistry ;
32
33
33
34
/**
34
35
* Default limits per page
@@ -41,9 +42,11 @@ class ProductList
41
42
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
42
43
*/
43
44
public function __construct (
44
- \Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig
45
+ \Magento \Framework \App \Config \ScopeConfigInterface $ scopeConfig ,
46
+ \Magento \Framework \Registry $ coreRegistry
45
47
) {
46
48
$ this ->scopeConfig = $ scopeConfig ;
49
+ $ this ->coreRegistry = $ coreRegistry ;
47
50
}
48
51
49
52
/**
@@ -97,6 +100,12 @@ public function getDefaultViewMode($options = [])
97
100
*/
98
101
public function getDefaultSortField ()
99
102
{
103
+ $ currentCategory = $ this ->coreRegistry ->registry ('current_category ' );
104
+ if ($ currentCategory ){
105
+ $ currentCategorySortBy = $ currentCategory ->getDefaultSortBy ();
106
+ return $ currentCategorySortBy ;
107
+ }
108
+
100
109
return $ this ->scopeConfig ->getValue (
101
110
\Magento \Catalog \Model \Config::XML_PATH_LIST_DEFAULT_SORT_BY ,
102
111
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
You can’t perform that action at this time.
0 commit comments