Produced by Araxis Merge on 2023-07-12 04:42:37 +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/ResourceModel/Fulltext | Collection.php | 2022-12-08 01:34:28 +0000 |
| 2 | Porto v4.0.6/Theme Files/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/ResourceModel/Fulltext | Collection.php | 2023-05-05 02:25:46 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 62 | 1648 |
| Changed | 7 | 26 |
| Inserted | 39 | 46 |
| Removed | 15 | 26 |
| 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\ResourceModel\Fulltext; | 22 | namespace Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext; | |||
| 23 | 23 | |||||
| 24 | use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory; | |||||
| 24 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker; | 25 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker; | |||
| 25 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyCheckerInterface; | 26 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyCheckerInterface; | |||
| 26 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverInterface; | |||||
| 27 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverFactory; | |||||
| 28 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverInterface; | |||||
| 29 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverFactory; | 27 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverFactory; | |||
| 28 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolverInterface; | |||||
| 30 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory; | 29 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierFactory; | |||
| 31 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierInterface; | 30 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierInterface; | |||
| 32 | use Magento\Framework\DB\Select; | 31 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverFactory; | |||
| 33 | use Magento\Framework\Api\Search\SearchResultInterface; | 32 | use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\TotalRecordsResolverInterface; | |||
| 34 | use Magento\CatalogSearch\Model\Search\RequestGenerator; | 33 | use Magento\CatalogSearch\Model\Search\RequestGenerator; | |||
| 34 | use Magento\Framework\Api\Search\SearchResultFactory; | |||||
| 35 | use Magento\Framework\Api\Search\SearchResultInterface; | |||||
| 36 | use Magento\Framework\App\ObjectManager; | |||||
| 37 | use Magento\Framework\DB\Select; | |||||
| 35 | use Magento\Framework\EntityManager\MetadataPool; | 38 | use Magento\Framework\EntityManager\MetadataPool; | |||
| 39 | use Magento\Framework\Exception\LocalizedException; | |||||
| 36 | use Magento\Framework\Exception\StateException; | 40 | use Magento\Framework\Exception\StateException; | |||
| 37 | use Magento\Framework\Search\Request\EmptyRequestDataException; | 41 | use Magento\Framework\Search\Request\EmptyRequestDataException; | |||
| 38 | use Magento\Framework\Search\Request\NonExistingRequestNameException; | 42 | use Magento\Framework\Search\Request\NonExistingRequestNameException; | |||
| 39 | use Magento\Framework\Api\Search\SearchResultFactory; | |||||
| 40 | use Magento\Framework\Exception\LocalizedException; | |||||
| 41 | use Magento\Framework\App\ObjectManager; | |||||
| 42 | use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory; | |||||
| 43 | use Magento\Store\Model\Store; | 43 | use Magento\Store\Model\Store; | |||
| 44 | 44 | |||||
| 45 | /** | 45 | /** | |||
| 46 | * Fulltext Collection | 46 | * Fulltext Collection | |||
| 47 | * | 47 | * | |||
| 48 | * This collection should be refactored to not have dependencies on MySQL-specific implementation. | 48 | * This collection should be refactored to not have dependencies on MySQL-specific implementation. | |||
| 49 | * | 49 | * | |||
| 50 | * @api | 50 | * @api | |||
| 51 | * @since 100.0.2 | 51 | * @since 100.0.2 | |||
| 52 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) | 52 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects) | |||
| 53 | * @SuppressWarnings(PHPMD.TooManyFields) | 53 | * @SuppressWarnings(PHPMD.TooManyFields) | |||
| 54 | * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | 54 | * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | |||
| 55 | */ | 55 | */ | |||
| 56 | class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection | 56 | class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection | |||
| 57 | { | 57 | { | |||
| 58 | /** | 58 | /** | |||
| 59 | * @var string | 59 | * @var string | |||
| 60 | */ | 60 | */ | |||
| 61 | private $queryText; | 61 | private $queryText; | |||
| 62 | 62 | |||||
| 63 | /** | 63 | /** | |||
| 64 | * @var string | 64 | * @var string | |||
| 65 | */ | 65 | */ | |||
| 66 | private $searchRequestName; | 66 | private $searchRequestName; | |||
| 67 | 67 | |||||
| 68 | /** | 68 | /** | |||
| 69 | * @var \Magento\Search\Api\SearchInterface | 69 | * @var \Magento\Search\Api\SearchInterface | |||
| 70 | */ | 70 | */ | |||
| 71 | private $search; | 71 | private $search; | |||
| 72 | 72 | |||||
| 73 | /** | 73 | /** | |||
| 74 | * @var \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder | 74 | * @var \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder | |||
| 75 | */ | 75 | */ | |||
| 76 | private $searchCriteriaBuilder; | 76 | private $searchCriteriaBuilder; | |||
| 77 | 77 | |||||
| 78 | /** | 78 | /** | |||
| 79 | * @var \Magento\Framework\Api\Search\SearchResultInterface | 79 | * @var \Magento\Framework\Api\Search\SearchResultInterface | |||
| 80 | */ | 80 | */ | |||
| 81 | private $searchResult; | 81 | private $searchResult; | |||
| 82 | 82 | |||||
| 83 | /** | 83 | /** | |||
| 84 | * @var SearchResultFactory | 84 | * @var SearchResultFactory | |||
| 85 | */ | 85 | */ | |||
| 86 | private $searchResultFactory; | 86 | private $searchResultFactory; | |||
| 87 | 87 | |||||
| 88 | /** | 88 | /** | |||
| 89 | * @var \Magento\Framework\Api\FilterBuilder | 89 | * @var \Magento\Framework\Api\FilterBuilder | |||
| 90 | */ | 90 | */ | |||
| 91 | private $filterBuilder; | 91 | private $filterBuilder; | |||
| 92 | 92 | |||||
| 93 | /** | 93 | /** | |||
| 94 | * @var SearchCriteriaResolverFactory | 94 | * @var SearchCriteriaResolverFactory | |||
| 95 | */ | 95 | */ | |||
| 96 | private $searchCriteriaResolverFactory; | 96 | private $searchCriteriaResolverFactory; | |||
| 97 | 97 | |||||
| 98 | /** | 98 | /** | |||
| 99 | * @var SearchResultApplierFactory | 99 | * @var SearchResultApplierFactory | |||
| 100 | */ | 100 | */ | |||
| 101 | private $searchResultApplierFactory; | 101 | private $searchResultApplierFactory; | |||
| 102 | 102 | |||||
| 103 | /** | 103 | /** | |||
| 104 | * @var TotalRecordsResolverFactory | 104 | * @var TotalRecordsResolverFactory | |||
| 105 | */ | 105 | */ | |||
| 106 | private $totalRecordsResolverFactory; | 106 | private $totalRecordsResolverFactory; | |||
| 107 | 107 | |||||
| 108 | /** | 108 | /** | |||
| 109 | * @var array | 109 | * @var array | |||
| 110 | */ | 110 | */ | |||
| 111 | private $searchOrders; | 111 | private $searchOrders; | |||
| 112 | 112 | |||||
| 113 | /** | 113 | /** | |||
| 114 | * @var DefaultFilterStrategyApplyCheckerInterface | 114 | * @var DefaultFilterStrategyApplyCheckerInterface | |||
| 115 | */ | 115 | */ | |||
| 116 | private $defaultFilterStrategyApplyChecker; | 116 | private $defaultFilterStrategyApplyChecker; | |||
| 117 | 117 | |||||
| 118 | /** @var Collection|null Clone collection */ | 118 | /** @var Collection|null Clone collection */ | |||
| 119 | public $collectionClone = null; | 119 | public $collectionClone = null; | |||
| 120 | 120 | |||||
| 121 | /** @var bool If this variable is True, the search result will not separate item by page */ | 121 | /** @var bool If this variable is True, the search result will not separate item by page */ | |||
| 122 | protected $_getAllData = false; | 122 | protected $_getAllData = false; | |||
| 123 | 123 | |||||
| 124 | /** | 124 | /** | |||
| 125 | * Collection constructor. | |||||
| 126 | * | |||||
| 125 | * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory | 127 | * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory | |||
| 126 | * @param \Psr\Log\LoggerInterface $logger | 128 | * @param \Psr\Log\LoggerInterface $logger | |||
| 127 | * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy | 129 | * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy | |||
| 128 | * @param \Magento\Framework\Event\ManagerInterface $eventManager | 130 | * @param \Magento\Framework\Event\ManagerInterface $eventManager | |||
| 129 | * @param \Magento\Eav\Model\Config $eavConfig | 131 | * @param \Magento\Eav\Model\Config $eavConfig | |||
| 130 | * @param \Magento\Framework\App\ResourceConnection $resource | 132 | * @param \Magento\Framework\App\ResourceConnection $resource | |||
| 131 | * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory | 133 | * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory | |||
| 132 | * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper | 134 | * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper | |||
| 133 | * @param \Magento\Framework\Validator\UniversalFactory $universalFactory | 135 | * @param \Magento\Framework\Validator\UniversalFactory $universalFactory | |||
| 134 | * @param \Magento\Store\Model\StoreManagerInterface $storeManager | 136 | * @param \Magento\Store\Model\StoreManagerInterface $storeManager | |||
| 135 | * @param \Magento\Framework\Module\Manager $moduleManager | 137 | * @param \Magento\Framework\Module\Manager $moduleManager | |||
| 136 | * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState | 138 | * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState | |||
| 137 | * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | 139 | * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig | |||
| 138 | * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory | 140 | * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory | |||
| 139 | * @param \Magento\Catalog\Model\ResourceModel\Url $catalogUrl | 141 | * @param \Magento\Catalog\Model\ResourceModel\Url $catalogUrl | |||
| 140 | * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate | 142 | * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate | |||
| 141 | * @param \Magento\Customer\Model\Session $customerSession | 143 | * @param \Magento\Customer\Model\Session $customerSession | |||
| 142 | * @param \Magento\Framework\Stdlib\DateTime $dateTime | 144 | * @param \Magento\Framework\Stdlib\DateTime $dateTime | |||
| 143 | * @param \Magento\Customer\Api\GroupManagementInterface $groupManagement | 145 | * @param \Magento\Customer\Api\GroupManagementInterface $groupManagement | |||
| 144 | * @param mixed $catalogSearchData | 146 | * @param SearchResultFactory $searchResultFactory | |||
| 145 | * @param mixed $requestBuilder | 147 | * @param \Magento\Search\Api\SearchInterface $search | |||
| 146 | * @param mixed $searchEngine | 148 | * @param null $catalogSearchData | |||
| 147 | * @param mixed $temporaryStorageFactory | 149 | * @param null $requestBuilder | |||
| 150 | * @param null $searchEngine | |||||
| 151 | * @param null $temporaryStorageFactory | |||||
| 148 | * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection | 152 | * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection | |||
| 149 | * @param string $searchRequestName | 153 | * @param string $searchRequestName | |||
| 150 | * @param SearchResultFactory|null $searchResultFactory | |||||
| 151 | * @param ProductLimitationFactory|null $productLimitationFactory | 154 | * @param ProductLimitationFactory|null $productLimitationFactory | |||
| 152 | * @param MetadataPool|null $metadataPool | 155 | * @param MetadataPool|null $metadataPool | |||
| 153 | * @param \Magento\Search\Api\SearchInterface|null $search | |||||
| 154 | * @param \Magento\Framework\Api\Search\SearchCriteriaBuilder|null $searchCriteriaBuilder | 156 | * @param \Magento\Framework\Api\Search\SearchCriteriaBuilder|null $searchCriteriaBuilder | |||
| 155 | * @param \Magento\Framework\Api\FilterBuilder|null $filterBuilder | 157 | * @param \Magento\Framework\Api\FilterBuilder|null $filterBuilder | |||
| 156 | * @param SearchCriteriaResolverFactory|null $searchCriteriaResolverFactory | 158 | * @param SearchCriteriaResolverFactory|null $searchCriteriaResolverFactory | |||
| 157 | * @param SearchResultApplierFactory|null $searchResultApplierFactory | 159 | * @param SearchResultApplierFactory|null $searchResultApplierFactory | |||
| 158 | * @param TotalRecordsResolverFactory|null $totalRecordsResolverFactory | 160 | * @param TotalRecordsResolverFactory|null $totalRecordsResolverFactory | |||
| 159 | * @param DefaultFilterStrategyApplyCheckerInterface|null $defaultFilterStrategyApplyChecker | 161 | * @param DefaultFilterStrategyApplyCheckerInterface|null $defaultFilterStrategyApplyChecker | |||
| 160 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) | |||||
| 161 | * @SuppressWarnings(PHPMD.NPathComplexity) | |||||
| 162 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) | |||||
| 163 | */ | 162 | */ | |||
| 164 | public function __construct( | 163 | public function __construct( | |||
| 165 | \Magento\Framework\Data\Collection\EntityFactory $entityFactory, | 164 | \Magento\Framework\Data\Collection\EntityFactory $entityFactory, | |||
| 166 | \Psr\Log\LoggerInterface $logger, | 165 | \Psr\Log\LoggerInterface $logger, | |||
| 167 | \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, | 166 | \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, | |||
| 168 | \Magento\Framework\Event\ManagerInterface $eventManager, | 167 | \Magento\Framework\Event\ManagerInterface $eventManager, | |||
| 169 | \Magento\Eav\Model\Config $eavConfig, | 168 | \Magento\Eav\Model\Config $eavConfig, | |||
| 170 | \Magento\Framework\App\ResourceConnection $resource, | 169 | \Magento\Framework\App\ResourceConnection $resource, | |||
| 171 | \Magento\Eav\Model\EntityFactory $eavEntityFactory, | 170 | \Magento\Eav\Model\EntityFactory $eavEntityFactory, | |||
| 172 | \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, | 171 | \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, | |||
| 173 | \Magento\Framework\Validator\UniversalFactory $universalFactory, | 172 | \Magento\Framework\Validator\UniversalFactory $universalFactory, | |||
| 174 | \Magento\Store\Model\StoreManagerInterface $storeManager, | 173 | \Magento\Store\Model\StoreManagerInterface $storeManager, | |||
| 175 | \Magento\Framework\Module\Manager $moduleManager, | 174 | \Magento\Framework\Module\Manager $moduleManager, | |||
| 176 | \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, | 175 | \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, | |||
| 177 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, | 176 | \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, | |||
| 178 | \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, | 177 | \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, | |||
| 179 | \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, | 178 | \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, | |||
| 180 | \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, | 179 | \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, | |||
| 181 | \Magento\Customer\Model\Session $customerSession, | 180 | \Magento\Customer\Model\Session $customerSession, | |||
| 182 | \Magento\Framework\Stdlib\DateTime $dateTime, | 181 | \Magento\Framework\Stdlib\DateTime $dateTime, | |||
| 183 | \Magento\Customer\Api\GroupManagementInterface $groupManagement, | 182 | \Magento\Customer\Api\GroupManagementInterface $groupManagement, | |||
| 183 | SearchResultFactory $searchResultFactory, | |||||
| 184 | \Magento\Search\Api\SearchInterface $search, | |||||
| 184 | $catalogSearchData = null, | 185 | $catalogSearchData = null, | |||
| 185 | $requestBuilder = null, | 186 | $requestBuilder = null, | |||
| 186 | $searchEngine = null, | 187 | $searchEngine = null, | |||
| 187 | $temporaryStorageFactory = null, | 188 | $temporaryStorageFactory = null, | |||
| 188 | \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, | 189 | \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, | |||
| 189 | $searchRequestName = 'catalog_view_container', | 190 | $searchRequestName = 'catalog_view_container', | |||
| 190 | SearchResultFactory $searchResultFactory = null, | |||||
| 191 | ProductLimitationFactory $productLimitationFactory = null, | 191 | ProductLimitationFactory $productLimitationFactory = null, | |||
| 192 | MetadataPool $metadataPool = null, | 192 | MetadataPool $metadataPool = null, | |||
| 193 | \Magento\Search\Api\SearchInterface $search = null, | |||||
| 194 | \Magento\Framework\Api\Search\SearchCriteriaBuilder $searchCriteriaBuilder = null, | 193 | \Magento\Framework\Api\Search\SearchCriteriaBuilder $searchCriteriaBuilder = null, | |||
| 195 | \Magento\Framework\Api\FilterBuilder $filterBuilder = null, | 194 | \Magento\Framework\Api\FilterBuilder $filterBuilder = null, | |||
| 196 | SearchCriteriaResolverFactory $searchCriteriaResolverFactory = null, | 195 | SearchCriteriaResolverFactory $searchCriteriaResolverFactory = null, | |||
| 197 | SearchResultApplierFactory $searchResultApplierFactory = null, | 196 | SearchResultApplierFactory $searchResultApplierFactory = null, | |||
| 198 | TotalRecordsResolverFactory $totalRecordsResolverFactory = null, | 197 | TotalRecordsResolverFactory $totalRecordsResolverFactory = null, | |||
| 199 | DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null | 198 | DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null | |||
| 200 | ) { | 199 | ) { | |||
| 201 | $this->searchResultFactory = $searchResultFactory ?? \Magento\Framework\App\ObjectManager::getInstance() | |||||
| 202 | ->get(\Magento\Framework\Api\Search\SearchResultFactory::class); | |||||
| 203 | parent::__construct( | 200 | parent::__construct( | |||
| 204 | $entityFactory, | 201 | $entityFactory, | |||
| 205 | $logger, | 202 | $logger, | |||
| 206 | $fetchStrategy, | 203 | $fetchStrategy, | |||
| 207 | $eventManager, | 204 | $eventManager, | |||
| 208 | $eavConfig, | 205 | $eavConfig, | |||
| 209 | $resource, | 206 | $resource, | |||
| 210 | $eavEntityFactory, | 207 | $eavEntityFactory, | |||
| 211 | $resourceHelper, | 208 | $resourceHelper, | |||
| 212 | $universalFactory, | 209 | $universalFactory, | |||
| 213 | $storeManager, | 210 | $storeManager, | |||
| 214 | $moduleManager, | 211 | $moduleManager, | |||
| 215 | $catalogProductFlatState, | 212 | $catalogProductFlatState, | |||
| 216 | $scopeConfig, | 213 | $scopeConfig, | |||
| 217 | $productOptionFactory, | 214 | $productOptionFactory, | |||
| 218 | $catalogUrl, | 215 | $catalogUrl, | |||
| 219 | $localeDate, | 216 | $localeDate, | |||
| 220 | $customerSession, | 217 | $customerSession, | |||
| 221 | $dateTime, | 218 | $dateTime, | |||
| 222 | $groupManagement, | 219 | $groupManagement, | |||
| 223 | $connection, | 220 | $connection, | |||
| 224 | $productLimitationFactory, | 221 | $productLimitationFactory, | |||
| 225 | $metadataPool | 222 | $metadataPool | |||
| 226 | ); | 223 | ); | |||
| 227 | $this->searchRequestName = $searchRequestName; | 224 | $this->searchRequestName = $searchRequestName; | |||
| 228 | $this->search = $search ?: ObjectManager::getInstance()->get(\Magento\Search\Api\SearchInterface::class); | 225 | $this->searchResultFactory = $searchResultFactory; | |||
| 226 | $this->search = $search; | |||||
| 229 | $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance() | 227 | $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance() | |||
| 230 | ->get(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder::class); | 228 | ->get(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder::class); | |||
| 231 | $this->filterBuilder = $filterBuilder ?: ObjectManager::getInstance() | 229 | $this->filterBuilder = $filterBuilder ?: ObjectManager::getInstance() | |||
| 232 | ->get(\Magento\Framework\Api\FilterBuilder::class); | 230 | ->get(\Magento\Framework\Api\FilterBuilder::class); | |||
| 233 | $this->searchCriteriaResolverFactory = $searchCriteriaResolverFactory ?: ObjectManager::getInstance() | 231 | $this->searchCriteriaResolverFactory = $searchCriteriaResolverFactory ?: ObjectManager::getInstance() | |||
| 234 | ->get(SearchCriteriaResolverFactory::class); | 232 | ->get(SearchCriteriaResolverFactory::class); | |||
| 235 | $this->searchResultApplierFactory = $searchResultApplierFactory ?: ObjectManager::getInstance() | 233 | $this->searchResultApplierFactory = $searchResultApplierFactory ?: ObjectManager::getInstance() | |||
| 236 | ->get(SearchResultApplierFactory::class); | 234 | ->get(SearchResultApplierFactory::class); | |||
| 237 | $this->totalRecordsResolverFactory = $totalRecordsResolverFactory ?: ObjectManager::getInstance() | 235 | $this->totalRecordsResolverFactory = $totalRecordsResolverFactory ?: ObjectManager::getInstance() | |||
| 238 | ->get(TotalRecordsResolverFactory::class); | 236 | ->get(TotalRecordsResolverFactory::class); | |||
| 239 | $this->defaultFilterStrategyApplyChecker = $defaultFilterStrategyApplyChecker ?: ObjectManager::getInstance() | 237 | $this->defaultFilterStrategyApplyChecker = $defaultFilterStrategyApplyChecker ?: ObjectManager::getInstance() | |||
| 240 | ->get(DefaultFilterStrategyApplyChecker::class); | 238 | ->get(DefaultFilterStrategyApplyChecker::class); | |||
| 241 | } | 239 | } | |||
| 242 | 240 | |||||
| 243 | /** | 241 | /** | |||
| 244 | * MP function Clone collection | 242 | * MP function Clone collection | |||
| 245 | * | 243 | * | |||
| 246 | * @param bool $isReturn | 244 | * @param bool $isReturn | |||
| 245 | * | |||||
| 247 | * @return $this|Collection | 246 | * @return $this|Collection | |||
| 248 | */ | 247 | */ | |||
| 249 | public function getCollectionClone($isReturn = true) | 248 | public function getCollectionClone($isReturn = true) | |||
| 250 | { | 249 | { | |||
| 251 | if ($this->collectionClone === null) { | 250 | if ($this->collectionClone === null) { | |||
| 252 | $this->collectionClone = clone $this; | 251 | $this->collectionClone = clone $this; | |||
| 253 | $this->collectionClone->setSearchCriteriaBuilder($this->searchCriteriaBuilder->cloneObject()); | 252 | $this->collectionClone->setSearchCriteriaBuilder($this->searchCriteriaBuilder->cloneObject()); | |||
| 254 | } | 253 | } | |||
| 255 | 254 | |||||
| 256 | if ($isReturn) { | 255 | if ($isReturn) { | |||
| 257 | $searchCriterialBuilder = $this->collectionClone->getSearchCriteriaBuilder()->cloneObject(); | 256 | $searchCriterialBuilder = $this->collectionClone->getSearchCriteriaBuilder()->cloneObject(); | |||
| 258 | 257 | |||||
| 259 | /** @var Collection $collectionClone */ | 258 | /** @var Collection $collectionClone */ | |||
| 260 | $collectionClone = clone $this->collectionClone; | 259 | $collectionClone = clone $this->collectionClone; | |||
| 261 | $collectionClone->setSearchCriteriaBuilder($searchCriterialBuilder); | 260 | $collectionClone->setSearchCriteriaBuilder($searchCriterialBuilder); | |||
| 262 | 261 | |||||
| 263 | return $collectionClone; | 262 | return $collectionClone; | |||
| 264 | } | 263 | } | |||
| 265 | 264 | |||||
| 266 | return $this; | 265 | return $this; | |||
| 267 | } | 266 | } | |||
| 268 | 267 | |||||
| 269 | /** | 268 | /** | |||
| 270 | * MP function remove attribute from collection to count product in option attribute | 269 | * MP function remove attribute from collection to count product in option attribute | |||
| 271 | * | 270 | * | |||
| 272 | * @param $attributeCode | 271 | * @param $attributeCode | |||
| 272 | * | |||||
| 273 | * @return Collection | 273 | * @return Collection | |||
| 274 | */ | 274 | */ | |||
| 275 | public function removeAttributeSearch($attributeCode) | 275 | public function removeAttributeSearch($attributeCode) | |||
| 276 | { | 276 | { | |||
| 277 | if (is_array($attributeCode)) { | 277 | if (is_array($attributeCode)) { | |||
| 278 | foreach ($attributeCode as $attCode) { | 278 | foreach ($attributeCode as $attCode) { | |||
| 279 | $this->searchCriteriaBuilder->removeFilter($attCode); | 279 | $this->searchCriteriaBuilder->removeFilter($attCode); | |||
| 280 | } | 280 | } | |||
| 281 | } else { | 281 | } else { | |||
| 282 | $this->searchCriteriaBuilder->removeFilter($attributeCode); | 282 | $this->searchCriteriaBuilder->removeFilter($attributeCode); | |||
| 283 | } | 283 | } | |||
| 284 | 284 | |||||
| 285 | $this->_isFiltersRendered = false; | 285 | $this->_isFiltersRendered = false; | |||
| 286 | 286 | |||||
| 287 | return $this->loadWithFilter(); | 287 | return $this->loadWithFilter(); | |||
| 288 | } | 288 | } | |||
| 289 | 289 | |||||
| 290 | /** | 290 | /** | |||
| 291 | * MP function Add multi-filter categories | 291 | * MP function Add multi-filter categories | |||
| 292 | * | 292 | * | |||
| 293 | * @param $categories | 293 | * @param $categories | |||
| 294 | * | 294 | * | |||
| 295 | * @return $this | 295 | * @return $this | |||
| 296 | */ | 296 | */ | |||
| 297 | public function addLayerCategoryFilter($categories) | 297 | public function addLayerCategoryFilter($categories) | |||
| 298 | { | 298 | { | |||
| 299 | $this->addFieldToFilter('category_ids', ['in' => $categories]); | 299 | $this->addFieldToFilter('category_ids', ['in' => $categories]); | |||
| 300 | 300 | |||||
| 301 | return $this; | 301 | return $this; | |||
| 302 | } | 302 | } | |||
| 303 | 303 | |||||
| 304 | /** | 304 | /** | |||
| 305 | * MP function reset category filter | 305 | * MP function reset category filter | |||
| 306 | * | 306 | * | |||
| 307 | * @param $categoryIds | 307 | * @param $categoryIds | |||
| 308 | * | |||||
| 308 | * @return $this | 309 | * @return $this | |||
| 309 | */ | 310 | */ | |||
| 310 | public function resetCategoryFilter($categoryIds) | 311 | public function resetCategoryFilter($categoryIds) | |||
| 311 | { | 312 | { | |||
| 312 | $this->searchCriteriaBuilder->setCategoryFilter($categoryIds); | 313 | $this->searchCriteriaBuilder->setCategoryFilter($categoryIds); | |||
| 313 | 314 | |||||
| 314 | return $this; | 315 | return $this; | |||
| 315 | } | 316 | } | |||
| 316 | 317 | |||||
| 317 | /** | 318 | /** | |||
| 318 | * MP function set category filter | 319 | * MP function set category filter | |||
| 319 | * | 320 | * | |||
| 320 | * @param $categoryIds | 321 | * @param $categoryIds | |||
| 322 | * | |||||
| 321 | * @return Collection | 323 | * @return Collection | |||
| 322 | */ | 324 | */ | |||
| 323 | public function setCategoryFilter($categoryIds) | 325 | public function setCategoryFilter($categoryIds) | |||
| 324 | { | 326 | { | |||
| 325 | $this->searchCriteriaBuilder->setCategoryFilter($categoryIds); | 327 | $this->searchCriteriaBuilder->setCategoryFilter($categoryIds); | |||
| 326 | $this->_isFiltersRendered = false; | 328 | $this->_isFiltersRendered = false; | |||
| 327 | 329 | |||||
| 328 | return $this->loadWithFilter(); | 330 | return $this->loadWithFilter(); | |||
| 329 | } | 331 | } | |||
| 330 | 332 | |||||
| 331 | /** | 333 | /** | |||
| 332 | * MP function reset category ids | 334 | * MP function reset category ids | |||
| 333 | * | 335 | * | |||
| 334 | * @param string $categoryIds | 336 | * @param string $categoryIds | |||
| 337 | * | |||||
| 335 | * @return $this | 338 | * @return $this | |||
| 336 | */ | 339 | */ | |||
| 337 | public function resetCategoryIds($categoryIds) | 340 | public function resetCategoryIds($categoryIds) | |||
| 338 | { | 341 | { | |||
| 339 | $this->_productLimitationFilters['category_id'] = $categoryIds; | 342 | $this->_productLimitationFilters['category_id'] = $categoryIds; | |||
| 340 | if ($this->getStoreId() == Store::DEFAULT_STORE_ID) { | 343 | if ($this->getStoreId() == Store::DEFAULT_STORE_ID) { | |||
| 341 | $this->_applyZeroStoreProductLimitations(); | 344 | $this->_applyZeroStoreProductLimitations(); | |||
| 342 | } else { | 345 | } else { | |||
| 343 | $this->_applyProductLimitations(); | 346 | $this->_applyProductLimitations(); | |||
| 344 | } | 347 | } | |||
| 345 | 348 | |||||
| 346 | return $this; | 349 | return $this; | |||
| 347 | } | 350 | } | |||
| 348 | 351 | |||||
| 349 | /** | 352 | /** | |||
| 350 | * MP function Reset Total records | 353 | * MP function Reset Total records | |||
| 351 | * | 354 | * | |||
| 352 | * @return $this | 355 | * @return $this | |||
| 353 | */ | 356 | */ | |||
| 354 | public function resetTotalRecords() | 357 | public function resetTotalRecords() | |||
| 355 | { | 358 | { | |||
| 356 | $this->_totalRecords = null; | 359 | $this->_totalRecords = null; | |||
| 357 | 360 | |||||
| 358 | return $this; | 361 | return $this; | |||
| 359 | } | 362 | } | |||
| 360 | 363 | |||||
| 361 | /** | 364 | /** | |||
| 362 | * Get search. | 365 | * Get search. | |||
| 363 | * | 366 | * | |||
| 364 | * @deprecated 100.1.0 | |||||
| 365 | * @return \Magento\Search\Api\SearchInterface | 367 | * @return \Magento\Search\Api\SearchInterface | |||
| 368 | * @deprecated 100.1.0 | |||||
| 366 | */ | 369 | */ | |||
| 367 | private function getSearch() | 370 | private function getSearch() | |||
| 368 | { | 371 | { | |||
| 369 | if ($this->search === null) { | 372 | if ($this->search === null) { | |||
| 370 | $this->search = ObjectManager::getInstance()->get(\Magento\Search\Api\SearchInterface::class); | 373 | $this->search = ObjectManager::getInstance()->get(\Magento\Search\Api\SearchInterface::class); | |||
| 371 | } | 374 | } | |||
| 375 | ||||||
| 372 | return $this->search; | 376 | return $this->search; | |||
| 373 | } | 377 | } | |||
| 374 | 378 | |||||
| 375 | /** | 379 | /** | |||
| 376 | * Test search. | 380 | * Test search. | |||
| 377 | * | 381 | * | |||
| 378 | * @deprecated 100.1.0 | |||||
| 379 | * @param \Magento\Search\Api\SearchInterface $object | 382 | * @param \Magento\Search\Api\SearchInterface $object | |||
| 383 | * | |||||
| 380 | * @return void | 384 | * @return void | |||
| 385 | * @deprecated 100.1.0 | |||||
| 381 | * @since 100.1.0 | 386 | * @since 100.1.0 | |||
| 382 | */ | 387 | */ | |||
| 383 | public function setSearch(\Magento\Search\Api\SearchInterface $object) | 388 | public function setSearch(\Magento\Search\Api\SearchInterface $object) | |||
| 384 | { | 389 | { | |||
| 385 | $this->search = $object; | 390 | $this->search = $object; | |||
| 386 | } | 391 | } | |||
| 387 | 392 | |||||
| 388 | /** | 393 | /** | |||
| 389 | * Set search criteria builder. | 394 | * Set search criteria builder. | |||
| 390 | * | 395 | * | |||
| 391 | * @deprecated 100.1.0 | |||||
| 392 | * @return \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder | 396 | * @return \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder | |||
| 397 | * @deprecated 100.1.0 | |||||
| 393 | */ | 398 | */ | |||
| 394 | private function getSearchCriteriaBuilder() | 399 | private function getSearchCriteriaBuilder() | |||
| 395 | { | 400 | { | |||
| 396 | if ($this->searchCriteriaBuilder === null) { | 401 | if ($this->searchCriteriaBuilder === null) { | |||
| 397 | $this->searchCriteriaBuilder = ObjectManager::getInstance() | 402 | $this->searchCriteriaBuilder = ObjectManager::getInstance() | |||
| 398 | ->get(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder::class); | 403 | ->get(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder::class); | |||
| 399 | } | 404 | } | |||
| 405 | ||||||
| 400 | return $this->searchCriteriaBuilder; | 406 | return $this->searchCriteriaBuilder; | |||
| 401 | } | 407 | } | |||
| 402 | 408 | |||||
| 403 | /** | 409 | /** | |||
| 404 | * Set search criteria builder. | 410 | * Set search criteria builder. | |||
| 405 | * | 411 | * | |||
| 406 | * @deprecated 100.1.0 | |||||
| 407 | * @param \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder $object | 412 | * @param \Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder $object | |||
| 413 | * | |||||
| 408 | * @return void | 414 | * @return void | |||
| 415 | * @deprecated 100.1.0 | |||||
| 409 | * @since 100.1.0 | 416 | * @since 100.1.0 | |||
| 410 | */ | 417 | */ | |||
| 411 | public function setSearchCriteriaBuilder(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder $object) | 418 | public function setSearchCriteriaBuilder(\Mageplaza\LayeredNavigation\Model\Search\SearchCriteriaBuilder $object) | |||
| 412 | { | 419 | { | |||
| 413 | $this->searchCriteriaBuilder = $object; | 420 | $this->searchCriteriaBuilder = $object; | |||
| 414 | } | 421 | } | |||
| 415 | 422 | |||||
| 416 | /** | 423 | /** | |||
| 417 | * Get filter builder. | 424 | * Get filter builder. | |||
| 418 | * | 425 | * | |||
| 419 | * @deprecated 100.1.0 | |||||
| 420 | * @return \Magento\Framework\Api\FilterBuilder | 426 | * @return \Magento\Framework\Api\FilterBuilder | |||
| 427 | * @deprecated 100.1.0 | |||||
| 421 | */ | 428 | */ | |||
| 422 | private function getFilterBuilder() | 429 | private function getFilterBuilder() | |||
| 423 | { | 430 | { | |||
| 424 | if ($this->filterBuilder === null) { | 431 | if ($this->filterBuilder === null) { | |||
| 425 | $this->filterBuilder = ObjectManager::getInstance()->get(\Magento\Framework\Api\FilterBuilder::class); | 432 | $this->filterBuilder = ObjectManager::getInstance()->get(\Magento\Framework\Api\FilterBuilder::class); | |||
| 426 | } | 433 | } | |||
| 434 | ||||||
| 427 | return $this->filterBuilder; | 435 | return $this->filterBuilder; | |||
| 428 | } | 436 | } | |||
| 429 | 437 | |||||
| 430 | /** | 438 | /** | |||
| 431 | * Set filter builder. | 439 | * Set filter builder. | |||
| 432 | * | 440 | * | |||
| 433 | * @deprecated 100.1.0 | |||||
| 434 | * @param \Magento\Framework\Api\FilterBuilder $object | 441 | * @param \Magento\Framework\Api\FilterBuilder $object | |||
| 442 | * | |||||
| 435 | * @return void | 443 | * @return void | |||
| 444 | * @deprecated 100.1.0 | |||||
| 436 | * @since 100.1.0 | 445 | * @since 100.1.0 | |||
| 437 | */ | 446 | */ | |||
| 438 | public function setFilterBuilder(\Magento\Framework\Api\FilterBuilder $object) | 447 | public function setFilterBuilder(\Magento\Framework\Api\FilterBuilder $object) | |||
| 439 | { | 448 | { | |||
| 440 | $this->filterBuilder = $object; | 449 | $this->filterBuilder = $object; | |||
| 441 | } | 450 | } | |||
| 442 | 451 | |||||
| 443 | /** | 452 | /** | |||
| 444 | * Apply attribute filter to facet collection | 453 | * Apply attribute filter to facet collection | |||
| 445 | * | 454 | * | |||
| 446 | * @param string $field | 455 | * @param string $field | |||
| 447 | * @param mixed|null $condition | 456 | * @param mixed|null $condition | |||
| 457 | * | |||||
| 448 | * @return $this | 458 | * @return $this | |||
| 449 | */ | 459 | */ | |||
| 450 | public function addFieldToFilter($field, $condition = null) | 460 | public function addFieldToFilter($field, $condition = null) | |||
| 451 | { | 461 | { | |||
| 452 | if ($this->searchResult !== null && $this->request->getFullActionName() !== 'mpproductfinder_finder_find') { | 462 | if ($this->searchResult !== null && $this->request->getFullActionName() !== 'mpproductfinder_finder_find') { | |||
| 453 | throw new \RuntimeException('Illegal state'); | 463 | throw new \RuntimeException('Illegal state'); | |||
| 454 | } | 464 | } | |||
| 455 | 465 | |||||
| 456 | $this->getSearchCriteriaBuilder(); | 466 | $this->getSearchCriteriaBuilder(); | |||
| 457 | $this->getFilterBuilder(); | 467 | $this->getFilterBuilder(); | |||
| 458 | 468 | |||||
| 459 | if (isset($condition['in'])) { | 469 | if (isset($condition['in'])) { | |||
| 460 | $this->filterBuilder->setField($field); | 470 | $this->filterBuilder->setField($field); | |||
| 461 | $this->filterBuilder->setValue($condition['in']); | 471 | $this->filterBuilder->setValue($condition['in']); | |||
| 462 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 472 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 463 | } elseif (!is_array($condition) || !in_array(key($condition), ['from', 'to'], true)) { | 473 | } elseif (!is_array($condition) || !in_array(key($condition), ['from', 'to'], true)) { | |||
| 464 | $this->filterBuilder->setField($field); | 474 | $this->filterBuilder->setField($field); | |||
| 465 | $this->filterBuilder->setValue($condition); | 475 | $this->filterBuilder->setValue($condition); | |||
| 466 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 476 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 467 | } else { | 477 | } else { | |||
| 468 | if (!empty($condition['from'])) { | 478 | if (!empty($condition['from'])) { | |||
| 469 | $this->filterBuilder->setField("{$field}.from"); | 479 | $this->filterBuilder->setField("{$field}.from"); | |||
| 470 | $this->filterBuilder->setValue($condition['from']); | 480 | $this->filterBuilder->setValue($condition['from']); | |||
| 471 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 481 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 472 | } | 482 | } | |||
| 473 | if (!empty($condition['to'])) { | 483 | if (!empty($condition['to'])) { | |||
| 474 | $this->filterBuilder->setField("{$field}.to"); | 484 | $this->filterBuilder->setField("{$field}.to"); | |||
| 475 | $this->filterBuilder->setValue($condition['to']); | 485 | $this->filterBuilder->setValue($condition['to']); | |||
| 476 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 486 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 477 | } | 487 | } | |||
| 478 | } | 488 | } | |||
| 489 | ||||||
| 479 | return $this; | 490 | return $this; | |||
| 480 | } | 491 | } | |||
| 481 | 492 | |||||
| 482 | /** | 493 | /** | |||
| 483 | * @inheritDoc | 494 | * @inheritDoc | |||
| 484 | * @since 101.0.4 | 495 | * @since 101.0.4 | |||
| 485 | */ | 496 | */ | |||
| 486 | public function clear() | 497 | public function clear() | |||
| 487 | { | 498 | { | |||
| 488 | $this->searchResult = null; | 499 | $this->searchResult = null; | |||
| 489 | $this->setFlag('has_category_filter', false); | 500 | $this->setFlag('has_category_filter', false); | |||
| 490 | 501 | |||||
| 491 | return parent::clear(); | 502 | return parent::clear(); | |||
| 492 | } | 503 | } | |||
| 493 | 504 | |||||
| 494 | /** | 505 | /** | |||
| 495 | * @inheritDoc | 506 | * @inheritDoc | |||
| 496 | * @since 101.0.4 | 507 | * @since 101.0.4 | |||
| 497 | */ | 508 | */ | |||
| 498 | protected function _reset() | 509 | protected function _reset() | |||
| 499 | { | 510 | { | |||
| 500 | $this->searchResult = null; | 511 | $this->searchResult = null; | |||
| 501 | $this->setFlag('has_category_filter', false); | 512 | $this->setFlag('has_category_filter', false); | |||
| 502 | 513 | |||||
| 503 | return parent::_reset(); | 514 | return parent::_reset(); | |||
| 504 | } | 515 | } | |||
| 505 | 516 | |||||
| 506 | /** | 517 | /** | |||
| 507 | * @inheritdoc | 518 | * @inheritdoc | |||
| 508 | * @since 101.0.4 | 519 | * @since 101.0.4 | |||
| 509 | */ | 520 | */ | |||
| 510 | public function _loadEntities($printQuery = false, $logQuery = false) | 521 | public function _loadEntities($printQuery = false, $logQuery = false) | |||
| 511 | { | 522 | { | |||
| 512 | $this->getEntity(); | 523 | $this->getEntity(); | |||
| 513 | 524 | |||||
| 514 | $this->printLogQuery($printQuery, $logQuery); | 525 | $this->printLogQuery($printQuery, $logQuery); | |||
| 515 | 526 | |||||
| 516 | try { | 527 | try { | |||
| 517 | /** | 528 | /** | |||
| 518 | * Prepare select query | 529 | * Prepare select query | |||
| 519 | * @var string $query | 530 | * @var string $query | |||
| 520 | */ | 531 | */ | |||
| 521 | $query = $this->getSelect(); | 532 | $query = $this->getSelect(); | |||
| 522 | $rows = $this->_fetchAll($query); | 533 | $rows = $this->_fetchAll($query); | |||
| 523 | } catch (\Exception $e) { | |||||
| 524 | $this->printLogQuery(false, true, $query); | |||||
| 525 | throw $e; | |||||
| 526 | } | |||||
| 527 | 534 | |||||
| 528 | $position = 0; | 535 | $position = 0; | |||
| 529 | foreach ($rows as $value) { | 536 | foreach ($rows as $value) { | |||
| 530 | if ($this->getFlag('has_category_filter')) { | 537 | if ($this->getFlag('has_category_filter')) { | |||
| 531 | $value['cat_index_position'] = $position++; | 538 | $value['cat_index_position'] = $position++; | |||
| 532 | } | 539 | } | |||
| 533 | $object = $this->getNewEmptyItem()->setData($value); | 540 | $object = $this->getNewEmptyItem()->setData($value); | |||
| 534 | $this->addItem($object); | 541 | $this->addItem($object); | |||
| 535 | if (isset($this->_itemsById[$object->getId()])) { | 542 | if (isset($this->_itemsById[$object->getId()])) { | |||
| 536 | $this->_itemsById[$object->getId()][] = $object; | 543 | $this->_itemsById[$object->getId()][] = $object; | |||
| 537 | } else { | 544 | } else { | |||
| 538 | $this->_itemsById[$object->getId()] = [$object]; | 545 | $this->_itemsById[$object->getId()] = [$object]; | |||
| 539 | } | 546 | } | |||
| 540 | } | 547 | } | |||
| 541 | if ($this->getFlag('has_category_filter')) { | 548 | if ($this->getFlag('has_category_filter')) { | |||
| 542 | $this->setFlag('has_category_filter', false); | 549 | $this->setFlag('has_category_filter', false); | |||
| 543 | } | 550 | } | |||
| 551 | } catch (\Exception $e) { | |||||
| 552 | $this->printLogQuery(false, true, $query); | |||||
| 553 | } | |||||
| 544 | 554 | |||||
| 545 | return $this; | 555 | return $this; | |||
| 546 | } | 556 | } | |||
| 547 | 557 | |||||
| 548 | /** | 558 | /** | |||
| 549 | * Add search query filter | 559 | * Add search query filter | |||
| 550 | * | 560 | * | |||
| 551 | * @param string $query | 561 | * @param string $query | |||
| 562 | * | |||||
| 552 | * @return $this | 563 | * @return $this | |||
| 553 | */ | 564 | */ | |||
| 554 | public function addSearchFilter($query) | 565 | public function addSearchFilter($query) | |||
| 555 | { | 566 | { | |||
| 556 | $this->queryText = trim($this->queryText . ' ' . $query); | 567 | $this->queryText = trim($this->queryText . ' ' . $query); | |||
| 568 | ||||||
| 557 | return $this; | 569 | return $this; | |||
| 558 | } | 570 | } | |||
| 559 | 571 | |||||
| 560 | /** | 572 | /** | |||
| 561 | * @inheritdoc | 573 | * @inheritdoc | |||
| 562 | */ | 574 | */ | |||
| 563 | public function setOrder($attribute, $dir = Select::SQL_DESC) | 575 | public function setOrder($attribute, $dir = Select::SQL_DESC) | |||
| 564 | { | 576 | { | |||
| 565 | $this->setSearchOrder($attribute, $dir); | 577 | $this->setSearchOrder($attribute, $dir); | |||
| 566 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | 578 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | |||
| 567 | parent::setOrder($attribute, $dir); | 579 | parent::setOrder($attribute, $dir); | |||
| 568 | } | 580 | } | |||
| 569 | 581 | |||||
| 570 | return $this; | 582 | return $this; | |||
| 571 | } | 583 | } | |||
| 572 | 584 | |||||
| 573 | /** | 585 | /** | |||
| 574 | * Add attribute to sort order. | 586 | * Add attribute to sort order. | |||
| 575 | * | 587 | * | |||
| 576 | * @param string $attribute | 588 | * @param string $attribute | |||
| 577 | * @param string $dir | 589 | * @param string $dir | |||
| 590 | * | |||||
| 578 | * @return $this | 591 | * @return $this | |||
| 579 | * @since 101.0.2 | 592 | * @since 101.0.2 | |||
| 580 | */ | 593 | */ | |||
| 581 | public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC) | 594 | public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC) | |||
| 582 | { | 595 | { | |||
| 583 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | 596 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | |||
| 584 | parent::addAttributeToSort($attribute, $dir); | 597 | parent::addAttributeToSort($attribute, $dir); | |||
| 585 | } else { | 598 | } else { | |||
| 586 | $this->setOrder($attribute, $dir); | 599 | $this->setOrder($attribute, $dir); | |||
| 587 | } | 600 | } | |||
| 588 | 601 | |||||
| 589 | return $this; | 602 | return $this; | |||
| 590 | } | 603 | } | |||
| 591 | 604 | |||||
| 592 | /** | 605 | /** | |||
| 593 | * @inheritdoc | 606 | * @inheritdoc | |||
| 594 | */ | 607 | */ | |||
| 595 | protected function _renderFiltersBefore() | 608 | protected function _renderFiltersBefore() | |||
| 596 | { | 609 | { | |||
| 597 | if ($this->isLoaded()) { | 610 | if ($this->isLoaded()) { | |||
| 598 | return; | 611 | return; | |||
| 599 | } | 612 | } | |||
| 600 | 613 | |||||
| 601 | $this->getCollectionClone(false); | 614 | $this->getCollectionClone(false); | |||
| 602 | 615 | |||||
| 603 | if ($this->searchRequestName !== 'quick_search_container' | 616 | if ($this->searchRequestName !== 'quick_search_container' | |||
| 604 | || trim($this->queryText) !== '' | 617 | || trim($this->queryText) !== '' | |||
| 605 | ) { | 618 | ) { | |||
| 606 | $this->prepareSearchTermFilter(); | 619 | $this->prepareSearchTermFilter(); | |||
| 607 | $this->preparePriceAggregation(); | 620 | $this->preparePriceAggregation(); | |||
| 608 | 621 | |||||
| 609 | $searchCriteria = $this->getSearchCriteriaResolver()->resolve(); | 622 | $searchCriteria = $this->getSearchCriteriaResolver()->resolve(); | |||
| 610 | try { | 623 | try { | |||
| 611 | $this->searchResult = $this->getSearch()->search($searchCriteria); | 624 | $this->searchResult = $this->getSearch()->search($searchCriteria); | |||
| 612 | $this->_totalRecords = $this->getTotalRecordsResolver($this->searchResult)->resolve(); | 625 | $this->_totalRecords = $this->getTotalRecordsResolver($this->searchResult)->resolve(); | |||
| 613 | } catch (EmptyRequestDataException $e) { | 626 | } catch (EmptyRequestDataException $e) { | |||
| 614 | $this->searchResult = $this->createEmptyResult(); | 627 | $this->searchResult = $this->createEmptyResult(); | |||
| 615 | } catch (NonExistingRequestNameException $e) { | 628 | } catch (NonExistingRequestNameException $e) { | |||
| 616 | $this->_logger->error($e->getMessage()); | 629 | $this->_logger->error($e->getMessage()); | |||
| 617 | throw new LocalizedException(__('An error occurred. For details, see the error log.')); | 630 | throw new LocalizedException(__('An error occurred. For details, see the error log.')); | |||
| 618 | } | 631 | } | |||
| 619 | } else { | 632 | } else { | |||
| 620 | $this->searchResult = $this->createEmptyResult(); | 633 | $this->searchResult = $this->createEmptyResult(); | |||
| 621 | } | 634 | } | |||
| 622 | 635 | |||||
| 623 | $this->getSearchResultApplier($this->searchResult)->apply(); | 636 | $this->getSearchResultApplier($this->searchResult)->apply(); | |||
| 624 | parent::_renderFiltersBefore(); | 637 | parent::_renderFiltersBefore(); | |||
| 625 | } | 638 | } | |||
| 626 | 639 | |||||
| 627 | /** | 640 | /** | |||
| 628 | * Create empty search result | 641 | * Create empty search result | |||
| 629 | * | 642 | * | |||
| 630 | * @return SearchResultInterface | 643 | * @return SearchResultInterface | |||
| 631 | */ | 644 | */ | |||
| 632 | private function createEmptyResult() | 645 | private function createEmptyResult() | |||
| 633 | { | 646 | { | |||
| 634 | return $this->searchResultFactory->create()->setItems([]); | 647 | return $this->searchResultFactory->create()->setItems([]); | |||
| 635 | } | 648 | } | |||
| 636 | 649 | |||||
| 637 | /** | 650 | /** | |||
| 638 | * Set sort order for search query. | 651 | * Set sort order for search query. | |||
| 639 | * | 652 | * | |||
| 640 | * @param string $field | 653 | * @param string $field | |||
| 641 | * @param string $direction | 654 | * @param string $direction | |||
| 655 | * | |||||
| 642 | * @return void | 656 | * @return void | |||
| 643 | */ | 657 | */ | |||
| 644 | private function setSearchOrder($field, $direction) | 658 | private function setSearchOrder($field, $direction) | |||
| 645 | { | 659 | { | |||
| 646 | $field = (string) | 660 | $field = (string) $this->_getMappedField($field); | |||
| 647 | $direction = strtoupper($direction) == self::SORT_ORDER_ASC ? self::SORT_ORDER_ASC : self::SORT_ORDER_DESC; | 661 | $direction = strtoupper($direction) == self::SORT_ORDER_ASC ? self::SORT_ORDER_ASC : self::SORT_ORDER_DESC; | |||
| 648 | 662 | |||||
| 649 | $this->searchOrders[$field] = $direction; | 663 | $this->searchOrders[$field] = $direction; | |||
| 650 | } | 664 | } | |||
| 651 | 665 | |||||
| 652 | /** | 666 | /** | |||
| 653 | * Get total records resolver. | 667 | * Get total records resolver. | |||
| 654 | * | 668 | * | |||
| 655 | * @param SearchResultInterface $searchResult | 669 | * @param SearchResultInterface $searchResult | |||
| 670 | * | |||||
| 656 | * @return TotalRecordsResolverInterface | 671 | * @return TotalRecordsResolverInterface | |||
| 657 | */ | 672 | */ | |||
| 658 | private function getTotalRecordsResolver(SearchResultInterface $searchResult): TotalRecordsResolverInterface | 673 | private function getTotalRecordsResolver(SearchResultInterface $searchResult): TotalRecordsResolverInterface | |||
| 659 | { | 674 | { | |||
| 660 | return $this->totalRecordsResolverFactory->create( | 675 | return $this->totalRecordsResolverFactory->create( | |||
| 661 | [ | 676 | [ | |||
| 662 | 'searchResult' => $searchResult, | 677 | 'searchResult' => $searchResult, | |||
| 663 | ] | 678 | ] | |||
| 664 | ); | 679 | ); | |||
| 665 | } | 680 | } | |||
| 666 | 681 | |||||
| 667 | /** | 682 | /** | |||
| 668 | * Function to change the _getAllData variable | 683 | * Function to change the _getAllData variable | |||
| 669 | * | 684 | * | |||
| 670 | * @param $isGetAll | 685 | * @param $isGetAll | |||
| 686 | * | |||||
| 671 | * @return $this | 687 | * @return $this | |||
| 672 | */ | 688 | */ | |||
| 673 | public function setGetAllData($isGetAll){ | 689 | public function setGetAllData($isGetAll) | |||
| 690 | { | |||||
| 674 | $this->_getAllData = $isGetAll; | 691 | $this->_getAllData = $isGetAll; | |||
| 675 | 692 | |||||
| 676 | return $this; | 693 | return $this; | |||
| 677 | } | 694 | } | |||
| 678 | 695 | |||||
| 679 | /** | 696 | /** | |||
| 680 | * Get search criteria resolver. | 697 | * Get search criteria resolver. | |||
| 681 | * | 698 | * | |||
| 682 | * @return SearchCriteriaResolverInterface | 699 | * @return SearchCriteriaResolverInterface | |||
| 683 | */ | 700 | */ | |||
| 684 | private function getSearchCriteriaResolver(): SearchCriteriaResolverInterface | 701 | private function getSearchCriteriaResolver(): SearchCriteriaResolverInterface | |||
| 685 | { | 702 | { | |||
| 686 | $size = $this->_getAllData ? 1000 : $this->getPageSize(); | 703 | $size = $this->_getAllData ? 1000 : $this->getPageSize(); | |||
| 687 | $currentPage = $this->_getAllData ? 1 : (int) | 704 | $currentPage = $this->_getAllData ? 1 : (int) $this->_curPage; | |||
| 688 | 705 | |||||
| 689 | return $this->searchCriteriaResolverFactory->create( | 706 | return $this->searchCriteriaResolverFactory->create( | |||
| 690 | [ | 707 | [ | |||
| 691 | 'builder' => $this->getSearchCriteriaBuilder(), | 708 | 'builder' => $this->getSearchCriteriaBuilder(), | |||
| 692 | 'collection' => $this, | 709 | 'collection' => $this, | |||
| 693 | 'searchRequestName' => $this->searchRequestName, | 710 | 'searchRequestName' => $this->searchRequestName, | |||
| 694 | 'currentPage' => $currentPage, | 711 | 'currentPage' => $currentPage, | |||
| 695 | 'size' => $size, | 712 | 'size' => $size, | |||
| 696 | 'orders' => $this->searchOrders, | 713 | 'orders' => $this->searchOrders, | |||
| 697 | ] | 714 | ] | |||
| 698 | ); | 715 | ); | |||
| 699 | } | 716 | } | |||
| 700 | 717 | |||||
| 701 | /** | 718 | /** | |||
| 702 | * Get search result applier. | 719 | * Get search result applier. | |||
| 703 | * | 720 | * | |||
| 704 | * @param SearchResultInterface $searchResult | 721 | * @param SearchResultInterface $searchResult | |||
| 722 | * | |||||
| 705 | * @return SearchResultApplierInterface | 723 | * @return SearchResultApplierInterface | |||
| 706 | */ | 724 | */ | |||
| 707 | private function getSearchResultApplier(SearchResultInterface $searchResult): SearchResultApplierInterface | 725 | private function getSearchResultApplier(SearchResultInterface $searchResult): SearchResultApplierInterface | |||
| 708 | { | 726 | { | |||
| 709 | $size = $this->_getAllData ? 1000 : $this->getPageSize(); | 727 | $size = $this->_getAllData ? 1000 : $this->getPageSize(); | |||
| 710 | $currentPage = $this->_getAllData ? 1 : (int) | 728 | $currentPage = $this->_getAllData ? 1 : (int) $this->_curPage; | |||
| 711 | 729 | |||||
| 712 | return $this->searchResultApplierFactory->create( | 730 | return $this->searchResultApplierFactory->create( | |||
| 713 | [ | 731 | [ | |||
| 714 | 'collection' => $this, | 732 | 'collection' => $this, | |||
| 715 | 'searchResult' => $searchResult, | 733 | 'searchResult' => $searchResult, | |||
| 716 | /** This variable sets by serOrder method, but doesn't have a getter method. */ | 734 | /** This variable sets by serOrder method, but doesn't have a getter method. */ | |||
| 717 | 'orders' => $this->_orders, | 735 | 'orders' => $this->_orders, | |||
| 718 | 'size' => $size, | 736 | 'size' => $size, | |||
| 719 | 'currentPage' => $currentPage, | 737 | 'currentPage' => $currentPage, | |||
| 720 | ] | 738 | ] | |||
| 721 | ); | 739 | ); | |||
| 722 | } | 740 | } | |||
| 723 | 741 | |||||
| 724 | /** | 742 | /** | |||
| 725 | * @inheritdoc | 743 | * @inheritdoc | |||
| 726 | * @since 100.2.3 | 744 | * @since 100.2.3 | |||
| 727 | */ | 745 | */ | |||
| 728 | protected function _beforeLoad() | 746 | protected function _beforeLoad() | |||
| 729 | { | 747 | { | |||
| 730 | /* | 748 | /* | |||
| 731 | * This order is required to force search results be the same | 749 | * This order is required to force search results be the same | |||
| 732 | * for the same requests and products with the same relevance | 750 | * for the same requests and products with the same relevance | |||
| 733 | * NOTE: this does not replace existing orders but ADDs one more | 751 | * NOTE: this does not replace existing orders but ADDs one more | |||
| 734 | */ | 752 | */ | |||
| 735 | $this->setOrder('entity_id'); | 753 | $this->setOrder('entity_id'); | |||
| 754 | ||||||
| 736 | return parent::_beforeLoad(); | 755 | return parent::_beforeLoad(); | |||
| 737 | } | 756 | } | |||
| 738 | 757 | |||||
| 739 | /** | 758 | /** | |||
| 740 | * Render filters. | 759 | * Render filters. | |||
| 741 | * | 760 | * | |||
| 742 | * @return $this | 761 | * @return $this | |||
| 743 | */ | 762 | */ | |||
| 744 | protected function _renderFilters() | 763 | protected function _renderFilters() | |||
| 745 | { | 764 | { | |||
| 746 | $this->_filters = []; | 765 | $this->_filters = []; | |||
| 766 | ||||||
| 747 | return parent::_renderFilters(); | 767 | return parent::_renderFilters(); | |||
| 748 | } | 768 | } | |||
| 749 | 769 | |||||
| 750 | /** | 770 | /** | |||
| 751 | * Stub method for compatibility with other search engines | 771 | * Stub method for compatibility with other search engines | |||
| 752 | * | 772 | * | |||
| 753 | * @return $this | 773 | * @return $this | |||
| 754 | */ | 774 | */ | |||
| 755 | public function setGeneralDefaultQuery() | 775 | public function setGeneralDefaultQuery() | |||
| 756 | { | 776 | { | |||
| 757 | return $this; | 777 | return $this; | |||
| 758 | } | 778 | } | |||
| 759 | 779 | |||||
| 760 | /** | 780 | /** | |||
| 761 | * Return field faceted data from faceted search result | 781 | * Return field faceted data from faceted search result | |||
| 762 | * | 782 | * | |||
| 763 | * @param string $field | 783 | * @param string $field | |||
| 784 | * | |||||
| 764 | * @return array | 785 | * @return array | |||
| 765 | * @throws StateException | 786 | * @throws StateException | |||
| 766 | */ | 787 | */ | |||
| 767 | public function getFacetedData($field) | 788 | public function getFacetedData($field) | |||
| 768 | { | 789 | { | |||
| 769 | $this->_renderFilters(); | 790 | $this->_renderFilters(); | |||
| 770 | $result = []; | 791 | $result = []; | |||
| 771 | $aggregations = $this->searchResult->getAggregations(); | 792 | $aggregations = $this->searchResult->getAggregations(); | |||
| 772 | // This behavior is for case with empty object when we got EmptyRequestDataException | 793 | // This behavior is for case with empty object when we got EmptyRequestDataException | |||
| 773 | if (null !== $aggregations) { | 794 | if (null !== $aggregations) { | |||
| 774 | $bucket = $aggregations->getBucket($field . RequestGenerator::BUCKET_SUFFIX); | 795 | $bucket = $aggregations->getBucket($field . RequestGenerator::BUCKET_SUFFIX); | |||
| 775 | if ($bucket) { | 796 | if ($bucket) { | |||
| 776 | foreach ($bucket->getValues() as $value) { | 797 | foreach ($bucket->getValues() as $value) { | |||
| 777 | $metrics = $value->getMetrics(); | 798 | $metrics = $value->getMetrics(); | |||
| 778 | $result[$metrics['value']] = $metrics; | 799 | $result[$metrics['value']] = $metrics; | |||
| 779 | } | 800 | } | |||
| 780 | } else { | 801 | } else { | |||
| 781 | throw new StateException(__("The bucket doesn't exist.")); | 802 | throw new StateException(__("The bucket doesn't exist.")); | |||
| 782 | } | 803 | } | |||
| 783 | } | 804 | } | |||
| 805 | ||||||
| 784 | return $result; | 806 | return $result; | |||
| 785 | } | 807 | } | |||
| 786 | 808 | |||||
| 787 | /** | 809 | /** | |||
| 788 | * Specify category filter for product collection | 810 | * Specify category filter for product collection | |||
| 789 | * | 811 | * | |||
| 790 | * @param \Magento\Catalog\Model\Category $category | 812 | * @param \Magento\Catalog\Model\Category $category | |||
| 813 | * | |||||
| 791 | * @return $this | 814 | * @return $this | |||
| 792 | */ | 815 | */ | |||
| 793 | public function addCategoryFilter(\Magento\Catalog\Model\Category $category) | 816 | public function addCategoryFilter(\Magento\Catalog\Model\Category $category) | |||
| 794 | { | 817 | { | |||
| 795 | $this->addFieldToFilter('category_ids', $category->getId()); | 818 | $this->addFieldToFilter('category_ids', $category->getId()); | |||
| 796 | /** | 819 | /** | |||
| 797 | * This changes need in backward compatible reasons for support dynamic improved algorithm | 820 | * This changes need in backward compatible reasons for support dynamic improved algorithm | |||
| 798 | * for price aggregation process. | 821 | * for price aggregation process. | |||
| 799 | */ | 822 | */ | |||
| 800 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | 823 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | |||
| 801 | parent::addCategoryFilter($category); | 824 | parent::addCategoryFilter($category); | |||
| 802 | } else { | 825 | } else { | |||
| 803 | $this->setFlag('has_category_filter', true); | 826 | $this->setFlag('has_category_filter', true); | |||
| 804 | $this->_productLimitationPrice(); | 827 | $this->_productLimitationPrice(); | |||
| 805 | } | 828 | } | |||
| 806 | 829 | |||||
| 807 | return $this; | 830 | return $this; | |||
| 808 | } | 831 | } | |||
| 809 | 832 | |||||
| 810 | /** | 833 | /** | |||
| 811 | * Set product visibility filter for enabled products | 834 | * Set product visibility filter for enabled products | |||
| 812 | * | 835 | * | |||
| 813 | * @param array $visibility | 836 | * @param array $visibility | |||
| 837 | * | |||||
| 814 | * @return $this | 838 | * @return $this | |||
| 815 | */ | 839 | */ | |||
| 816 | public function setVisibility($visibility) | 840 | public function setVisibility($visibility) | |||
| 817 | { | 841 | { | |||
| 818 | $this->addFieldToFilter('visibility', $visibility); | 842 | $this->addFieldToFilter('visibility', $visibility); | |||
| 819 | /** | 843 | /** | |||
| 820 | * This changes need in backward compatible reasons for support dynamic improved algorithm | 844 | * This changes need in backward compatible reasons for support dynamic improved algorithm | |||
| 821 | * for price aggregation process. | 845 | * for price aggregation process. | |||
| 822 | */ | 846 | */ | |||
| 823 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | 847 | if ($this->defaultFilterStrategyApplyChecker->isApplicable()) { | |||
| 824 | parent::setVisibility($visibility); | 848 | parent::setVisibility($visibility); | |||
| 825 | } | 849 | } | |||
| 826 | 850 | |||||
| 827 | return $this; | 851 | return $this; | |||
| 828 | } | 852 | } | |||
| 829 | 853 | |||||
| 830 | /** | 854 | /** | |||
| 831 | * Prepare search term filter for text query. | 855 | * Prepare search term filter for text query. | |||
| 832 | * | 856 | * | |||
| 833 | * @return void | 857 | * @return void | |||
| 834 | */ | 858 | */ | |||
| 835 | private function prepareSearchTermFilter(): void | 859 | private function prepareSearchTermFilter(): void | |||
| 836 | { | 860 | { | |||
| 837 | if ($this->queryText) { | 861 | if ($this->queryText) { | |||
| 838 | $this->filterBuilder->setField('search_term'); | 862 | $this->filterBuilder->setField('search_term'); | |||
| 839 | $this->filterBuilder->setValue($this->queryText); | 863 | $this->filterBuilder->setValue($this->queryText); | |||
| 840 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 864 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 841 | } | 865 | } | |||
| 842 | } | 866 | } | |||
| 843 | 867 | |||||
| 844 | /** | 868 | /** | |||
| 845 | * Prepare price aggregation algorithm. | 869 | * Prepare price aggregation algorithm. | |||
| 846 | * | 870 | * | |||
| 847 | * @return void | 871 | * @return void | |||
| 848 | */ | 872 | */ | |||
| 849 | private function preparePriceAggregation(): void | 873 | private function preparePriceAggregation(): void | |||
| 850 | { | 874 | { | |||
| 851 | $priceRangeCalculation = $this->_scopeConfig->getValue( | 875 | $priceRangeCalculation = $this->_scopeConfig->getValue( | |||
| 852 | \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, | 876 | \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmFactory::XML_PATH_RANGE_CALCULATION, | |||
| 853 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | 877 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE | |||
| 854 | ); | 878 | ); | |||
| 855 | if ($priceRangeCalculation) { | 879 | if ($priceRangeCalculation) { | |||
| 856 | $this->filterBuilder->setField('price_dynamic_algorithm'); | 880 | $this->filterBuilder->setField('price_dynamic_algorithm'); | |||
| 857 | $this->filterBuilder->setValue($priceRangeCalculation); | 881 | $this->filterBuilder->setValue($priceRangeCalculation); | |||
| 858 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | 882 | $this->searchCriteriaBuilder->addFilter($this->filterBuilder->create()); | |||
| 859 | } | 883 | } | |||
| 860 | } | 884 | } | |||
| 861 | } | 885 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.