Skip to content

Commit 2e828cd

Browse files
ENGCOM-5622: Validated input text fields to enter only blank spaces #23059
- Merge Pull Request #23059 from RonakParmar/magento2:23055_advanced_search_fix - Merged commits: 1. ddcf068 2. 14b90ed 3. a2ca170 4. 64c1131
2 parents 6f03dd3 + 64c1131 commit 2e828cd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/code/Magento/CatalogSearch/Model/Advanced.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ public function __construct(
181181
/**
182182
* Add advanced search filters to product collection
183183
*
184-
* @param array $values
185-
* @return $this
184+
* @param array $values
185+
* @return $this
186186
* @throws LocalizedException
187187
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
188188
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -197,6 +197,11 @@ public function addFilters($values)
197197
if (!isset($values[$attribute->getAttributeCode()])) {
198198
continue;
199199
}
200+
if ($attribute->getFrontendInput() == 'text' || $attribute->getFrontendInput() == 'textarea') {
201+
if (!trim($values[$attribute->getAttributeCode()])) {
202+
continue;
203+
}
204+
}
200205
$value = $values[$attribute->getAttributeCode()];
201206
$preparedSearchValue = $this->getPreparedSearchCriteria($attribute, $value);
202207
if (false === $preparedSearchValue) {
@@ -343,9 +348,9 @@ protected function addSearchCriteria($attribute, $value)
343348
*
344349
* @todo: Move this code to block
345350
*
346-
* @param EntityAttribute $attribute
347-
* @param mixed $value
348-
* @return string|bool
351+
* @param EntityAttribute $attribute
352+
* @param mixed $value
353+
* @return string|bool
349354
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
350355
* @SuppressWarnings(PHPMD.NPathComplexity)
351356
*/

0 commit comments

Comments
 (0)