Search by code without sumbols

  • Posts: 1027
  • Thank you received: 11
  • Hikashop Business
6 months 3 weeks ago #355628

-- HikaShop version -- : 4.7.5
-- Joomla version -- : 3.10.12

Hello!

I would like to be able to search by product code like this:
Let's say the product code is 11-22-333, if i put this code in the search box it works correctly. What i want is to add the code without the dashes (-) and still get results, for example 1122333 or 11 22 333.

Thank you

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

  • Posts: 4533
  • Thank you received: 612
  • MODERATOR
6 months 3 weeks ago #355632

Hello,

Take a look on my screenshot, and especiallt red bordered part, this should get you what you need:



Regards

Last edit: 6 months 3 weeks ago by Philip.
The following user(s) said Thank You: verzevoul

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

  • Posts: 1027
  • Thank you received: 11
  • Hikashop Business
6 months 3 weeks ago #355664

Hi!

I did it but it's not working. I need the search filter to apply to titles also not just code.

Thank you

Attachments:

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
6 months 3 weeks ago #355667

Hi,

There is no option to dynamically apply modifications to the texts being searched.
What you need to do is to create a custom field of the table "product" and of the type "text" or "textarea" where you can enter the product code without the dashes. Then, in your filter, also select that custom field and you'll find results for the product code without the dashes.
And you can also create a mass action to automatically fill the custom field with the product_code without the dashes with a mass action of the type "update the values" on the column of the custom field with the "operation" mode and the value:

replace({product.product_code},'-','')
(not tested)

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

  • Posts: 1027
  • Thank you received: 11
  • Hikashop Business
6 months 2 weeks ago #355719

Hi!

I created the custom field and did the filter as you said but the mass action didn't work.
The value of the custom field after i ran the mass action is 0.
Could you check the screenshots if everything is correct?

Thank you!

Attachments:

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

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
6 months 2 weeks ago #355725

Hi,

I would recommend doing it with a normal mass action (with a filter on the product_id to target only one product first) and see if you get any error when you run it.

Otherwise, you could also try running a MySQL query directly in the database via PHPMyAdmin. Something like that:

UPDATE #__hikashop_product SET search_column = replace(product_code,'-','');

The following user(s) said Thank You: verzevoul

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

Time to create page: 0.066 seconds
Powered by Kunena Forum