Jump to content

Reference id searchable?


Recommended Posts

I am using the product reference field in the product page to show the UPS / PART on the actual product page. The part number is going to be a huge benefit for the customer because a lot of them will come to the site already knowing the part number that they need based in an insert that they had received with their entire kit.

I had assumed that since it was called a reference number that it was something you could search but I just found out that my website is not searching the reference numbers. Is there any information about how to add this feature to the search?

Link to comment
Share on other sites

Yes I did check those threads but neither of them really give an explanation of how to make the reference searchable. I have actually put that reference number into every field (UPS, EAN, and REFERENCE) just to see and no one of them yield a searchable field.

thoughts?

here is a screen shot of one of my attributes

48354_UJs51TQy8NK2XxZBopfG_t

Link to comment
Share on other sites

I just recently installed 4.1.3 new final release (upgrade since I first made this post)

The issue is still happening.

You can go here:
LINK

There you can quickly copy a reference number and stick it in the search at the top.. You will see it returns 0 results.. that number I used on every single field in the create product box that I could.

Link to comment
Share on other sites

  • 2 weeks later...

Ok this has turned into a pain in the butt problem..

I did some research and did a bunch of testing and from what I read - reference numbers that are applied to combinations they do not get searched?? Whats the purpose of reference numbers for combinations then??

I tested by rebuilding the search index, checking ALL of the settings and searching various parts of the product reference number. The products come up if the reference id is in the tags or as the main product reference but I get no results if the reference number is applied to it's proper combination.

Does someone have a snippet that allows the search to search the combinations reference as well?

Link to comment
Share on other sites

  • 6 months later...

For anyone else trying to do this, I was able to add search functionality to combination reference numbers this way:

 

In classes/Search.php replace the getAttributes function with the following and then rebuild your index. Make sure you back up the file before doing this.

 

public static function getAttributes($db, $id_product, $id_lang)
{
$attributes = '';
$attributesArray = $db->ExecuteS('
SELECT al.name, pa.reference FROM '._DB_PREFIX_.'product_attribute pa
INNER JOIN '._DB_PREFIX_.'product_attribute_combination pac ON pa.id_product_attribute = pac.id_product_attribute
INNER JOIN '._DB_PREFIX_.'attribute_lang al ON (pac.id_attribute = al.id_attribute AND al.id_lang = '.(int)$id_lang.')
WHERE pa.id_product = '.(int)$id_product);
foreach ($attributesArray AS $attribute)
$attributes .= $attribute['name'].' ';
$attributes .= $attribute['reference'].' ';
return $attributes;
}

 

A better way would be to loop through each combination in addition to looping through each product, and indexing ALL of the fields appropriately. But this still works as a quick and dirty fix. You can allow searching of other combination fields by selecting them in the query and then adding them to the attributes string, just as I did with pa.reference and the $attribute['reference'] lines.

  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

Scott Z, great fix. I've been trying to find a solution to this issue since I launched my store, and in all that time this is the only working one I've found.

 

The only problem I encountered was that both of these fields together

 

 

$attributes .= $attribute['name'].' ';

$attributes .= $attribute['reference'].' ';

 

 

meant not all reference numbers were searchable. So for example a product with 10 different attributes, a proportion of them would throw up nothing for a search of their reference number. I just removed the 'name' line, effectively replacing it with 'reference' and now it works great. It's probably not a perfect solution, but it works for me.

 

On my store,attribute reference numbers are far more important than attribute names, so I could live without names being searchable, but even removing the name line of code it doesn't even look like anything's been negatively affected, or harder to find? I'll keep on monitoring it, but for now very happy with this fix.

Link to comment
Share on other sites

  • 2 weeks later...
×
×
  • Create New...