Stéphane1405 Posted October 6, 2015 Share Posted October 6, 2015 Hello world, I would like to get all products ids of products having a specific feature, I did not find a way to do it with getProducts(). Exemple : get all products whose style is classic. Any idea ? Cheers, Stéphane Link to comment Share on other sites More sharing options...
razaro Posted October 6, 2015 Share Posted October 6, 2015 Try to use this query $productsidsbyfeature = Db::getInstance()->executeS(' SELECT id_product, fl.name, value, pf.id_feature as id_feature FROM '._DB_PREFIX_.'feature_product pf LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = pf.id_feature AND fl.id_lang = '.(int)$context->language->id.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$context->language->id.') LEFT JOIN '._DB_PREFIX_.'feature f ON (f.id_feature = pf.id_feature) '.Shop::addSqlAssociation('feature', 'f').' WHERE fvl.`id_feature_value` = '. $id_of_selected_feature.' GROUP BY id_product ORDER BY f.position ASC '); Have used something similar in module I was working on. This part needs id of feature you want but if you can change that part to feature name maybe. Link to comment Share on other sites More sharing options...
Stéphane1405 Posted October 7, 2015 Author Share Posted October 7, 2015 It works . Thanks a lot for your help. 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