Jump to content

get products by feature programmatically


Stéphane1405

Recommended Posts

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

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...