Jump to content

Search within product_attribute.reference


skulaluks

Recommended Posts

Hi,
Prestashop searches normally trough product.reference, but once a product has multiple attributes and each attribute has its own reference code, search engine of prestashop cannot find it.

What should i change to make prestashop find a product whose attribute has reference code that i search?

The File to be modified is probably

\classes\Search.php



Thank you for your help

Link to comment
Share on other sites

I found it!

The file to be edited is:

\classes\Search.php



The lines from linenumber289 should look like this
only 2rows and 1 attribute to the query have to be added :

       $weightArray = array(
           'pname' => Configuration::get('PS_SEARCH_WEIGHT_PNAME'),
           'reference' => Configuration::get('PS_SEARCH_WEIGHT_REF'),
           'pareference' => Configuration::get('PS_SEARCH_WEIGHT_REF'), // add just this line here
           'ean13' => Configuration::get('PS_SEARCH_WEIGHT_REF'),
           'description_short' => Configuration::get('PS_SEARCH_WEIGHT_SHORTDESC'),
           'description' => Configuration::get('PS_SEARCH_WEIGHT_DESC'),
           'cname' => Configuration::get('PS_SEARCH_WEIGHT_CNAME'),
           'mname' => Configuration::get('PS_SEARCH_WEIGHT_MNAME'),
           'tags' => Configuration::get('PS_SEARCH_WEIGHT_TAG'),
           'attributes' => Configuration::get('PS_SEARCH_WEIGHT_ATTRIBUTE'),
           'features' => Configuration::get('PS_SEARCH_WEIGHT_FEATURE')
       );

       $products = $db->ExecuteS('
       SELECT p.id_product, pl.id_lang, pl.name as pname, p.reference, p.ean13, pl.description_short, pl.description, cl.name as cname, m.name as mname,
pa.reference as pareference
       FROM '._DB_PREFIX_.'product p
       LEFT JOIN '._DB_PREFIX_.'product_lang pl ON p.id_product = pl.id_product
       LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default AND pl.id_lang = cl.id_lang)
       LEFT JOIN '._DB_PREFIX_.'manufacturer m ON m.id_manufacturer = p.id_manufacturer
       left join '._DB_PREFIX_.'product_attribute pa ON pa.id_product = p.id_product   
       WHERE p.indexed = 0', false); // add just this line above this comment



Than you have to go to your backend admin>preferences>search> and run complete indexation of all products.

Link to comment
Share on other sites

  • 10 months later...
  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...