Produced by Araxis Merge on 2023-07-12 04:42:36 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v4.0.5/Theme Files/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer | Filter.php | 2022-12-08 01:34:28 +0000 |
| 2 | Porto v4.0.6/Theme Files/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer | Filter.php | 2023-05-05 02:25:46 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 1 | 420 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | <?php | 1 | <?php | |||
| 2 | /** | 2 | /** | |||
| 3 | * Mageplaza | 3 | * Mageplaza | |||
| 4 | * | 4 | * | |||
| 5 | * NOTICE OF LICENSE | 5 | * NOTICE OF LICENSE | |||
| 6 | * | 6 | * | |||
| 7 | * This source file is subject to the Mageplaza.com license that is | 7 | * This source file is subject to the Mageplaza.com license that is | |||
| 8 | * available through the world-wide-web at this URL: | 8 | * available through the world-wide-web at this URL: | |||
| 9 | * https://www.mageplaza.com/LICENSE.txt | 9 | * https://www.mageplaza.com/LICENSE.txt | |||
| 10 | * | 10 | * | |||
| 11 | * DISCLAIMER | 11 | * DISCLAIMER | |||
| 12 | * | 12 | * | |||
| 13 | * Do not edit or add to this file if you wish to upgrade this extension to newer | 13 | * Do not edit or add to this file if you wish to upgrade this extension to newer | |||
| 14 | * version in the future. | 14 | * version in the future. | |||
| 15 | * | 15 | * | |||
| 16 | * @category Mageplaza | 16 | * @category Mageplaza | |||
| 17 | * @package Mageplaza_LayeredNavigation | 17 | * @package Mageplaza_LayeredNavigation | |||
| 18 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | 18 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | |||
| 19 | * @license https://www.mageplaza.com/LICENSE.txt | 19 | * @license https://www.mageplaza.com/LICENSE.txt | |||
| 20 | */ | 20 | */ | |||
| 21 | 21 | |||||
| 22 | namespace Mageplaza\LayeredNavigation\Model\Layer; | 22 | namespace Mageplaza\LayeredNavigation\Model\Layer; | |||
| 23 | 23 | |||||
| 24 | use Magento\Catalog\Model\Layer\Filter\AbstractFilter; | 24 | use Magento\Catalog\Model\Layer\Filter\AbstractFilter; | |||
| 25 | use Magento\Catalog\Model\Layer\Filter\Item; | 25 | use Magento\Catalog\Model\Layer\Filter\Item; | |||
| 26 | use Magento\Framework\App\RequestInterface; | 26 | use Magento\Framework\App\RequestInterface; | |||
| 27 | use Magento\Framework\Exception\LocalizedException; | 27 | use Magento\Framework\Exception\LocalizedException; | |||
| 28 | use Magento\Framework\Exception\NoSuchEntityException; | 28 | use Magento\Framework\Exception\NoSuchEntityException; | |||
| 29 | use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; | 29 | use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; | |||
| 30 | use Mageplaza\LayeredNavigation\Model\Layer\Filter\Category; | 30 | use Mageplaza\LayeredNavigation\Model\Layer\Filter\Category; | |||
| 31 | 31 | |||||
| 32 | /** | 32 | /** | |||
| 33 | * Class Filter | 33 | * Class Filter | |||
| 34 | * @package Mageplaza\LayeredNavigation\Model\Layer | 34 | * @package Mageplaza\LayeredNavigation\Model\Layer | |||
| 35 | */ | 35 | */ | |||
| 36 | class Filter | 36 | class Filter | |||
| 37 | { | 37 | { | |||
| 38 | /** @var RequestInterface */ | 38 | /** @var RequestInterface */ | |||
| 39 | protected $request; | 39 | protected $request; | |||
| 40 | 40 | |||||
| 41 | /** @var array Slider types */ | 41 | /** @var array Slider types */ | |||
| 42 | protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER]; | 42 | protected $sliderTypes = [LayerHelper::FILTER_TYPE_SLIDER]; | |||
| 43 | 43 | |||||
| 44 | /** | 44 | /** | |||
| 45 | * Filter constructor. | 45 | * Filter constructor. | |||
| 46 | * | 46 | * | |||
| 47 | * @param RequestInterface $request | 47 | * @param RequestInterface $request | |||
| 48 | */ | 48 | */ | |||
| 49 | public function __construct(RequestInterface $request) | 49 | public function __construct(RequestInterface $request) | |||
| 50 | { | 50 | { | |||
| 51 | $this->request = $request; | 51 | $this->request = $request; | |||
| 52 | } | 52 | } | |||
| 53 | 53 | |||||
| 54 | /** | 54 | /** | |||
| 55 | * Layered configuration for js widget | 55 | * Layered configuration for js widget | |||
| 56 | * | 56 | * | |||
| 57 | * @param AbstractFilter $filters | 57 | * @param AbstractFilter $filters | |||
| 58 | * @param $config | 58 | * @param $config | |||
| 59 | * | 59 | * | |||
| 60 | * @return mixed | 60 | * @return mixed | |||
| 61 | */ | 61 | */ | |||
| 62 | public function getLayerConfiguration($filters, $config) | 62 | public function getLayerConfiguration($filters, $config) | |||
| 63 | { | 63 | { | |||
| 64 | $slider = []; | 64 | $slider = []; | |||
| 65 | foreach ($filters as $filter) { | 65 | foreach ($filters as $filter) { | |||
| 66 | if ($this->isSliderTypes($filter) && $filter->getItemsCount()) { | 66 | if ($this->isSliderTypes($filter) && $filter->getItemsCount()) { | |||
| 67 | $slider[$filter->getRequestVar()] = $filter->getSliderConfig(); | 67 | $slider[$filter->getRequestVar()] = $filter->getSliderConfig(); | |||
| 68 | } | 68 | } | |||
| 69 | } | 69 | } | |||
| 70 | $config->setData('slider', $slider); | 70 | $config->setData('slider', $slider); | |||
| 71 | 71 | |||||
| 72 | return $this; | 72 | return $this; | |||
| 73 | } | 73 | } | |||
| 74 | 74 | |||||
| 75 | /** | 75 | /** | |||
| 76 | * @param $filter | 76 | * @param $filter | |||
| 77 | * @param null $types | 77 | * @param null $types | |||
| 78 | * | 78 | * | |||
| 79 | * @return bool | 79 | * @return bool | |||
| 80 | */ | 80 | */ | |||
| 81 | public function isSliderTypes($filter, $types = null) | 81 | public function isSliderTypes($filter, $types = null) | |||
| 82 | { | 82 | { | |||
| 83 | $filterType = $this->getFilterType($filter); | 83 | $filterType = $this->getFilterType($filter); | |||
| 84 | $types = $types ?: $this->sliderTypes; | 84 | $types = $types ?: $this->sliderTypes; | |||
| 85 | 85 | |||||
| 86 | return in_array($filterType, $types, true); | 86 | return in_array($filterType, $types, true); | |||
| 87 | } | 87 | } | |||
| 88 | 88 | |||||
| 89 | /** | 89 | /** | |||
| 90 | * @param AbstractFilter $filter | 90 | * @param AbstractFilter $filter | |||
| 91 | * @param null $compareType | 91 | * @param null $compareType | |||
| 92 | * | 92 | * | |||
| 93 | * @return bool|string | 93 | * @return bool|string | |||
| 94 | * @throws NoSuchEntityException | 94 | * @throws NoSuchEntityException | |||
| 95 | */ | 95 | */ | |||
| 96 | public function getFilterType($filter, $compareType = null) | 96 | public function getFilterType($filter, $compareType = null) | |||
| 97 | { | 97 | { | |||
| 98 | $type = LayerHelper::FILTER_TYPE_LIST; | 98 | $type = LayerHelper::FILTER_TYPE_LIST; | |||
| 99 | if ($filter->getRequestVar() === 'price') { | 99 | if ($filter->getRequestVar() === 'price') { | |||
| 100 | $type = LayerHelper::FILTER_TYPE_SLIDER; | 100 | $type = LayerHelper::FILTER_TYPE_SLIDER; | |||
| 101 | } elseif ($filter->getRequestVar() === 'cat' | 101 | } elseif ($filter->getRequestVar() === 'cat' | |||
| 102 | && $filter instanceof Category | 102 | && $filter instanceof Category | |||
| 103 | && $filter->isRenderCategoryTree()) { | 103 | && $filter->isRenderCategoryTree()) { | |||
| 104 | $type = LayerHelper::FILTER_TYPE_TREE; | 104 | $type = LayerHelper::FILTER_TYPE_TREE; | |||
| 105 | } | 105 | } | |||
| 106 | 106 | |||||
| 107 | return $compareType ? ($type === $compareType) : $type; | 107 | return $compareType ? ($type === $compareType) : $type; | |||
| 108 | } | 108 | } | |||
| 109 | 109 | |||||
| 110 | /** | 110 | /** | |||
| 111 | * Get option url. If it has been filtered, return removed url. Else return filter url | 111 | * Get option url. If it has been filtered, return removed url. Else return filter url | |||
| 112 | * | 112 | * | |||
| 113 | * @param Item $item | 113 | * @param Item $item | |||
| 114 | * | 114 | * | |||
| 115 | * @return mixed | 115 | * @return mixed | |||
| 116 | */ | 116 | */ | |||
| 117 | public function getItemUrl($item) | 117 | public function getItemUrl($item) | |||
| 118 | { | 118 | { | |||
| 119 | if ($this->isSelected($item)) { | 119 | if ($this->isSelected($item)) { | |||
| 120 | return $item->getRemoveUrl(); | 120 | return $item->getRemoveUrl(); | |||
| 121 | } | 121 | } | |||
| 122 | 122 | |||||
| 123 | return $item->getUrl(); | 123 | return $item->getUrl(); | |||
| 124 | } | 124 | } | |||
| 125 | 125 | |||||
| 126 | /** | 126 | /** | |||
| 127 | * Check if option is selected or not | 127 | * Check if option is selected or not | |||
| 128 | * | 128 | * | |||
| 129 | * @param Item $item | 129 | * @param Item $item | |||
| 130 | * | 130 | * | |||
| 131 | * @return bool | 131 | * @return bool | |||
| 132 | * @throws LocalizedException | 132 | * @throws LocalizedException | |||
| 133 | */ | 133 | */ | |||
| 134 | public function isSelected(Item $item) | 134 | public function isSelected(Item $item) | |||
| 135 | { | 135 | { | |||
| 136 | $filterValue = $this->getFilterValue($item->getFilter()); | 136 | $filterValue = $this->getFilterValue($item->getFilter()); | |||
| 137 | 137 | |||||
| 138 | return !empty($filterValue) && in_array((string)$item->getValue(), $filterValue, true); | 138 | return !empty($filterValue) && in_array((string)$item->getValue(), $filterValue, true); | |||
| 139 | } | 139 | } | |||
| 140 | 140 | |||||
| 141 | /** | 141 | /** | |||
| 142 | * @param AbstractFilter $filter | 142 | * @param AbstractFilter $filter | |||
| 143 | * @param bool|true $explode | 143 | * @param bool|true $explode | |||
| 144 | * | 144 | * | |||
| 145 | * @return array|mixed | 145 | * @return array|mixed | |||
| 146 | */ | 146 | */ | |||
| 147 | public function getFilterValue($filter, $explode = true) | 147 | public function getFilterValue($filter, $explode = true) | |||
| 148 | { | 148 | { | |||
| 149 | $filterValue = $this->request->getParam($filter->getRequestVar()); | 149 | $filterValue = $this->request->getParam($filter->getRequestVar()); | |||
| 150 | if (empty($filterValue)) { | 150 | if (empty($filterValue)) { | |||
| 151 | return []; | 151 | return []; | |||
| 152 | } | 152 | } | |||
| 153 | 153 | |||||
| 154 | return $explode ? explode(',', $filterValue) : [$filterValue]; | 154 | return $explode ? explode(',', $filterValue) : [$filterValue]; | |||
| 155 | } | 155 | } | |||
| 156 | 156 | |||||
| 157 | /** | 157 | /** | |||
| 158 | * Allow to show counter after options | 158 | * Allow to show counter after options | |||
| 159 | * | 159 | * | |||
| 160 | * @param AbstractFilter $filter | 160 | * @param AbstractFilter $filter | |||
| 161 | * | 161 | * | |||
| 162 | * @return bool | 162 | * @return bool | |||
| 163 | */ | 163 | */ | |||
| 164 | public function isShowCounter($filter) | 164 | public function isShowCounter($filter) | |||
| 165 | { | 165 | { | |||
| 166 | return true; | 166 | return true; | |||
| 167 | } | 167 | } | |||
| 168 | 168 | |||||
| 169 | /** | 169 | /** | |||
| 170 | * Allow multiple filter | 170 | * Allow multiple filter | |||
| 171 | * | 171 | * | |||
| 172 | * @param AbstractFilter $filter | 172 | * @param AbstractFilter $filter | |||
| 173 | * | 173 | * | |||
| 174 | * @return bool | 174 | * @return bool | |||
| 175 | */ | 175 | */ | |||
| 176 | public function isMultiple($filter) | 176 | public function isMultiple($filter) | |||
| 177 | { | 177 | { | |||
| 178 | return !($this->isSliderTypes($filter) || $filter->getRequestVar() === 'price'); | 178 | return !($this->isSliderTypes($filter) || $filter->getRequestVar() === 'price'); | |||
| 179 | } | 179 | } | |||
| 180 | 180 | |||||
| 181 | /** | 181 | /** | |||
| 182 | * Checks whether the option reduces the number of results | 182 | * Checks whether the option reduces the number of results | |||
| 183 | * | 183 | * | |||
| 184 | * @param AbstractFilter $filter | 184 | * @param AbstractFilter $filter | |||
| 185 | * @param int $optionCount Count of search results with this option | 185 | * @param int $optionCount Count of search results with this option | |||
| 186 | * @param int $totalSize Current search results count | 186 | * @param int $totalSize Current search results count | |||
| 187 | * | 187 | * | |||
| 188 | * @return bool | 188 | * @return bool | |||
| 189 | */ | 189 | */ | |||
| 190 | public function isOptionReducesResults($filter, $optionCount, $totalSize) | 190 | public function isOptionReducesResults($filter, $optionCount, $totalSize) | |||
| 191 | { | 191 | { | |||
| 192 | $result = $optionCount <= $totalSize; | 192 | $result = $optionCount <= $totalSize; | |||
| 193 | 193 | |||||
| 194 | if ($this->isShowZero($filter)) { | 194 | if ($this->isShowZero($filter)) { | |||
| 195 | return $result; | 195 | return $result; | |||
| 196 | } | 196 | } | |||
| 197 | 197 | |||||
| 198 | return $optionCount && $result; | 198 | return $optionCount && $result; | |||
| 199 | } | 199 | } | |||
| 200 | 200 | |||||
| 201 | /** | 201 | /** | |||
| 202 | * @param AbstractFilter $filter | 202 | * @param AbstractFilter $filter | |||
| 203 | * | 203 | * | |||
| 204 | * @return bool | 204 | * @return bool | |||
| 205 | */ | 205 | */ | |||
| 206 | public function isShowZero($filter) | 206 | public function isShowZero($filter) | |||
| 207 | { | 207 | { | |||
| 208 | return false; | 208 | return false; | |||
| 209 | } | 209 | } | |||
| 210 | } | 210 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.