34 private $coreRegistry;
52 \
Magento\Framework\Registry::class
63 $value = $this->scopeConfig->getValue(
64 self::XML_PATH_LIST_MODE,
69 $availableMode = [
'grid' =>
__(
'Grid')];
73 $availableMode = [
'list' =>
__(
'List')];
77 $availableMode = [
'grid' =>
__(
'Grid'),
'list' =>
__(
'List')];
81 $availableMode = [
'list' =>
__(
'List'),
'grid' =>
__(
'Grid')];
84 $availableMode =
null;
87 return $availableMode;
101 return current(array_keys(
$options));
111 $currentCategory = $this->coreRegistry->registry(
'current_category');
112 if ($currentCategory) {
113 return $currentCategory->getDefaultSortBy();
116 return $this->scopeConfig->getValue(
130 if (!in_array(
$mode, [self::VIEW_MODE_GRID, self::VIEW_MODE_LIST])) {
133 $perPageConfigKey =
'catalog/frontend/' .
$mode .
'_per_page_values';
134 $perPageValues = (string)$this->scopeConfig->getValue(
138 $perPageValues = explode(
',', $perPageValues);
139 $perPageValues = array_combine($perPageValues, $perPageValues);
140 if ($this->scopeConfig->isSetFlag(
141 'catalog/frontend/list_allow_all',
144 return ($perPageValues + [
'all' =>
__(
'All')]);
146 return $perPageValues;
158 if ($viewMode == self::VIEW_MODE_LIST) {
159 return $this->scopeConfig->getValue(
160 'catalog/frontend/list_per_page',
163 }
elseif ($viewMode == self::VIEW_MODE_GRID) {
164 return $this->scopeConfig->getValue(
165 'catalog/frontend/grid_per_page',
elseif(isset( $params[ 'redirect_parent']))
getDefaultLimitPerPageValue($viewMode)
getDefaultViewMode($options=[])
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Registry $coreRegistry=null)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
const DEFAULT_SORT_DIRECTION