Searching product with sku ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 years ago
Thanks and this seems to be working but may i please know where to change / modify and how to do this? we are new to nopcommerce so please explain in details (how to do and which file to change) - can we do this through FTP ?

we want to do this ---
EXAMPLE
---------------
One of our product part number / sku is
EW-FT-2-1220-3000

Currently nopcommerce SEARCH function is working ONLY if we search the whole part number "EW-FT-2-1220-3000" in search box

we want it to search even if we enter "FT-2" and list all products having word "FT-2" found in part number field in database.

i think something just need to be changed in codes (like in php we used to do %% search string %% in select statement)
-------------

can somebody help us to get this done please?

thanks in advance!
2 years ago
Hi

All you need to do is modify the stored procedure ProductLoadAllPaged with the text from the previous post.  This will allow you search with the left hand 3 characters.

Go to vanillawoodfloors.co.uk and search for 306 to see this in action.

Thanks

Tony
2 years ago
mituloz wrote:
can we do this through FTP ?

No, to modify the Stored Procedure you need to access the Database with a Tool like Microsoft SQL Server Management Studio and Modify the procedure
2 years ago
I am sorry to bother you. I know PHP & MySQL but completely new to SQL Server Manaegment Studio. I have connected it to our database but dont know what you said to modify stored procedure.

Could you please tell me, how do i access a stored procedure "ProductLoadAllPaged" in visual studio?

Thanks.
2 years ago
OK guys i googled and found a stored procedure "ProductLoadAllPaged" on sql server management studio

    --SKU (exact match)
    IF @SearchSku = 1
    BEGIN
      SET @sql = @sql + 'OR p.[Sku] = @OriginalKeywords '
    END

anybody can guide me now what to change in order to put a LIKE "%...%" query there to search SKU with whatever string is prefix and suffix?

Eg:
If our SKU is EW-ABC-XYZ-700
currently, it displays a product in search if we search for the whole SKU = EW-ABC-XYZ-700

we want to implement if we search = EW-ABC or ABC or XYZ  etc... then also it must display a product containing anything we search in EW-ABC-XYX-700

thanks a lot guys for your kind help
2 years ago
mituloz wrote:
...if we search = EW-ABC or ABC or XYZ  etc... then also it must display a product containing anything we search in EW-ABC-XYX-700...


If you have SQL Server 2016 or greater, and OK with the "-" as the separator, then after the
SET @sql = @sql + 'OR p.[Sku] = @OriginalKeywords '
put this

IF CHARINDEX('-', @OriginalKeywords) > 0
    SELECT @sql =  @sql + ' OR p.[Sku] like ''%' + value + '%''' FROM STRING_SPLIT(@OriginalKeywords, '-')


will generate this
OR p.[Sku] = @OriginalKeywords  OR p.[Sku] like '%EW%' OR p.[Sku] like '%ABC%' OR p.[Sku] like '%XYZ%' OR p.[Sku] like '%700%'
2 years ago
Thank you so much for your kind help
2 years ago
hi

it searches on SKU properly the way we want. what if we want it to search into product description as well

can anybody please help with a code to write in "ProductLoadAllPaged" stored procedure so that if we can search on any word written in product description paragraph then all those products also get listed after searching?

eg:
there is a word "ground level" in one of the product description but it doesnt appear when we search from a search text box in header of our nopcommerce store. it only displays products if we tick those checkboxes of "advance search" on search page.

your help will be greatly appreciated.

thank you!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.