Quick search by product code?

Entering product code - SKU and get results that no products found, what am I doing wrong here? In addon settings this feature is enabled, cache cleared…

Doesn’t work on my 2.1.4 test shop either

[quote name=‘S-Combs’]Doesn’t work on my 2.1.4 test shop either[/QUOTE]



quick search it so far buggy addon…



first bug noticed some results with “…” instead of product names, now seach by code does not work…

I modified that addon because the settings didn’t seem to work and I also did not like how much extra data it added to the data base. All the information (product code, manufacturer, product name) I have already input into the Search words so I modified the file to only index the Search words. I posted this in the Hints forum.

Hello Darius,



It seems that the problem with searching of products by product code occurred because the quick search catalog was not generated. Open the settings page of the “Quick Search” add-on and click on the link in order to generate a full search phrases catalog.

[quote name=‘CS-Cart Support team’]Hello Darius,



It seems that the problem with searching of products by product code occurred because the quick search catalog was not generated. Open the settings page of the “Quick Search” add-on and click on the link in order to generate a full search phrases catalog.[/QUOTE]



Not true, I have generated and cleared cache minimum few times, cs-cart demo shop acted very same way as my fresh install.



PS it is registered as bug here

[url]http://forum.cs-cart.com/vbugs.php?do=view&vbug_id=2507[/url]

Thank you for the reply, Darius.



Searching by product code works correctly, but there was a minor bug in the current CS-Cart installation: the “quick search” functionality worked improperly if a product was updated. This happened because the catalog was already generated. In order to fix the bug, please take these steps:


  1. Replace this part of the code:


function fn_quick_search_update_product($product_data, $product_id, $lang_code, $create)
{
db_query('DELETE FROM ?:quick_search WHERE type = ?s AND item_id = ?i AND lang_code = ?s', 'p', $product_id, $lang_code);

$_update = array(
'product' => $product_data['product'],
'short_description' => isset($product_data['short_description']) ? $product_data['short_description'] : '',
'full_description' => isset($product_data['full_description']) ? $product_data['full_description'] : '',



with this one:


function fn_quick_search_update_product($product_data, $product_id, $lang_code, $create)
{
db_query('DELETE FROM ?:quick_search WHERE type IN (?a) AND item_id = ?i AND lang_code = ?s', array('p', 't', 's'), $product_id, $lang_code);

$_update = array(
'product' => $product_data['product'],
'product_code' => isset($product_data['product_code']) ? $product_data['product_code'] : '',
'short_description' => isset($product_data['short_description']) ? $product_data['short_description'] : '',
'full_description' => isset($product_data['full_description']) ? $product_data['full_description'] : '',



2) Replace this part of the code:


foreach ($_update as $field => $attr) {
if (!empty($attr)) {
($field == 'product') ? $type = 't' : $type = 'p';
if ($create) {



with this one:


foreach ($_update as $field => $attr) {
if (!empty($attr)) {
($field == 'product') ? $type = 't' : ($field == 'product_code' ? $type = 's' : $type = 'p');
if ($create) {



3) Replace this part of the code:


function fn_quick_search_delete_product($product_id)
{
db_query('DELETE FROM ?:quick_search WHERE (type = ?s OR type = ?s) AND item_id = ?i', 'p', 't', $product_id);
}




with this one:


function fn_quick_search_delete_product($product_id)
{
db_query('DELETE FROM ?:quick_search WHERE type IN (?a) AND item_id = ?i', array('p', 't', 's'), $product_id);
}



in the “func.php” file located in the “addons/quick_search” directory of your CS-Cart installation.