Text filter only on the whole word

  • Posts: 55
  • Thank you received: 0
9 years 9 months ago #189396

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.35
-- Browser(s) name and version -- : crome

Good morning, I'm configuring a filter textual hikashop bussines and I have to look for numbers in a custom field, my problem is that if the number in question has three digits is the right product, but if the number has only its digits is all products with three digits appear where those two.
An example: my products have a characteristic number, as I have three products, one is called the 789 one is called 89 and the other is called 123, and all belong to the same category, if I put in the text field 789 no problem, appears only the 789 but if I try the 89 shows both the 89 and 789 that I want to appear only 89. Among the selection items that attach not found anything that responds to the event.
Thank You

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189412

Hi,

That's how the system is made.
If you want to change that, you need to edit the file administrator/components/com_hikashop/classes/filter.php and remove all the % characters in the code:

if(@$searchProcessing != 'any'){
					foreach($terms as $term){
						if(empty($term)) continue;
						$array =array();
						foreach($searchField as $column){
							$array[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';
							$fields[] = ' reference_field = \''.$column.'\' ';
						}
						$list[]='('.implode(' OR ', $array).')';
						$translationList[] = 'value LIKE \'%'.hikashop_getEscaped($term, true).'%\'';
					}
					$filters[]='('.implode(' AND ', $list).')';
					$translationFilters =  '('.implode(' AND ', $translationList).')';
				}else{
					foreach($terms as $term){
						if(empty($term))
							continue;
						foreach($searchField as $column){
							$list[]=' b.'.$column.' LIKE \'%'.hikashop_getEscaped($term, true).'%\' ';
							$fields[] = ' reference_field = \''.$column.'\' ';
						}
						$translationList[] = 'value LIKE \'%'.hikashop_getEscaped($term, true).'%\'';
					}
					$filters[]='('.implode(' OR ', $list).')';
					$translationFilters =  '('.implode(' OR ', $translationList).')';
				}
Then, the filter will only match exact values.

The following user(s) said Thank You: gioferrario@gmail.com

Please Log in or Create an account to join the conversation.

  • Posts: 55
  • Thank you received: 0
9 years 9 months ago #189540

Wow perfect !! think that in future editions it was inserted as an option with choices from buttons?

Thank you very much

Please Log in or Create an account to join the conversation.

  • Posts: 82865
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189557

Hi,

Yes, we'll add an "exact" choice for the "search processing" option of the text filters in the next version in order to avoid the need for a code modification.

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum