nestor44 Posted July 11 Share Posted July 11 (edited) Hi, my search index included features. I do not need to index all features. I want to index only 3 features and their values. Is it possible to exclude certain features from search index? I am using PS 8.1.5 for one shop and PS 9 for the second shop. I want to exclude some features from both shops. Edited July 14 by nestor44 solved (see edit history) Link to comment Share on other sites More sharing options...
Prestashop Addict Posted July 12 Share Posted July 12 Can you precise your need? Link to comment Share on other sites More sharing options...
Paul C Posted July 13 Share Posted July 13 PrestaShop doesn't index feature names, only their values so you'll need to modify the function that retrieves just the values of the features you want. You can do it by adding an override to the Search class (sadly there are no hooks you can use). Below is an example of code you would place in override/classes/Search.php (you need to clear the cache when you add or remove files from the override directory): <?php class Search extends SearchCore { /** * @param Db $db * @param int $id_product * @param int $id_lang * * @return string */ public static function getFeatures($db, $id_product, $id_lang) { if (!Feature::isFeatureActive()) { return ''; } $features = ''; $featuresArray = $db->executeS(' SELECT fvl.value FROM ' . _DB_PREFIX_ . 'feature_product fp LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fp.id_feature_value = fvl.id_feature_value AND fvl.id_lang = ' . (int) $id_lang . ') WHERE fp.id_product = ' . (int) $id_product . ' AND fp.id_feature IN (1,2,3)', true, false); foreach ($featuresArray as $feature) { $features .= $feature['value'] . ' '; } return $features; } } The above will only add the values of features with id_feature = 1, 2 or 3 (obviously you need to replace 1, 2 and 3 with the IDs of the three features you want included in search). The above override should work for any PrestaShop version from 1.6 -> 9.0 (this function hasn't changed in all that time). 2 Link to comment Share on other sites More sharing options...
nestor44 Posted July 14 Author Share Posted July 14 @Paul C, thank you so much. That's exactly what I needed 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now