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