Skip to content

Commit 5781562

Browse files
committed
Fixes for last review #10937
1 parent 7257d41 commit 5781562

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/code/Magento/Catalog/Helper/Product/ProductList.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ class ProductList
2929
* @var \Magento\Framework\App\Config\ScopeConfigInterface
3030
*/
3131
protected $scopeConfig;
32-
protected $coreRegistry;
32+
33+
/**
34+
* @var \Magento\Framework\Registry
35+
*/
36+
private $coreRegistry;
3337

3438
/**
3539
* Default limits per page
@@ -43,10 +47,10 @@ class ProductList
4347
*/
4448
public function __construct(
4549
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
46-
\Magento\Framework\Registry $coreRegistry
50+
\Magento\Framework\Registry $coreRegistry = null
4751
) {
4852
$this->scopeConfig = $scopeConfig;
49-
$this->coreRegistry = $coreRegistry;
53+
$this->coreRegistry = $coreRegistry ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
5054
}
5155

5256
/**
@@ -102,8 +106,7 @@ public function getDefaultSortField()
102106
{
103107
$currentCategory = $this->coreRegistry->registry('current_category');
104108
if ($currentCategory) {
105-
$currentCategorySortBy = $currentCategory->getDefaultSortBy();
106-
return $currentCategorySortBy;
109+
return $currentCategory->getDefaultSortBy();
107110
}
108111

109112
return $this->scopeConfig->getValue(

0 commit comments

Comments
 (0)