Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Sortby.php
Go to the documentation of this file.
1 <?php
7 
13 class Sortby extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
14 {
20  protected $_catalogConfig;
21 
27  public function __construct(\Magento\Catalog\Model\Config $catalogConfig)
28  {
29  $this->_catalogConfig = $catalogConfig;
30  }
31 
37  protected function _getCatalogConfig()
38  {
39  return $this->_catalogConfig;
40  }
41 
45  public function getAllOptions()
46  {
47  if ($this->_options === null) {
48  $this->_options = [['label' => __('Position'), 'value' => 'position']];
49  foreach ($this->_getCatalogConfig()->getAttributesUsedForSortBy() as $attribute) {
50  $this->_options[] = [
51  'label' => __($attribute['frontend_label']),
52  'value' => $attribute['attribute_code'],
53  ];
54  }
55  }
56  return $this->_options;
57  }
58 }
__()
Definition: __.php:13
__construct(\Magento\Catalog\Model\Config $catalogConfig)
Definition: Sortby.php:27