frank_jarle Posted September 8, 2014 Share Posted September 8, 2014 In the section Catalog->Product Features I have created about 28 features that i use on my site: But when i do a product comparison, the order of the product features is messed up. The Product feature seems correct order when looking at the product page. Link to comment Share on other sites More sharing options...
wutend Posted September 25, 2014 Share Posted September 25, 2014 I have the same problem. Please help!!! Link to comment Share on other sites More sharing options...
Qvixx Posted September 25, 2014 Share Posted September 25, 2014 (edited) I'm not an expert, so I hope someone can look through this change. The code in classes/Feature.php looks like this (near line 246): return Db::getInstance()->executeS(' SELECT * , COUNT(*) as nb FROM `'._DB_PREFIX_.'feature` f LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature` LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature` WHERE fp.`id_product` IN ('.$ids.') AND `id_lang` = '.(int)$id_lang.' GROUP BY f.`id_feature` ORDER BY nb DESC That means the features are only sorted by the amount of products which have them set. That means features which are set in all products come before features that are set in only one product. Like this they should be sorted first by the number amount of products which have them set AND AFTERWARDS by their position: return Db::getInstance()->executeS(' SELECT * , COUNT(*) as nb FROM `'._DB_PREFIX_.'feature` f LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature` LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature` WHERE fp.`id_product` IN ('.$ids.') AND `id_lang` = '.(int)$id_lang.' GROUP BY f.`id_feature` ORDER BY nb DESC, position ASC And like this they should only be sorted by their Position return Db::getInstance()->executeS(' SELECT * , COUNT(*) as nb FROM `'._DB_PREFIX_.'feature` f LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature` LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature` WHERE fp.`id_product` IN ('.$ids.') AND `id_lang` = '.(int)$id_lang.' GROUP BY f.`id_feature` ORDER BY position ASC This depends on which behaviour you want to achieve. Greets Edited September 25, 2014 by Qvixx (see edit history) 1 Link to comment Share on other sites More sharing options...
wutend Posted September 25, 2014 Share Posted September 25, 2014 (edited) Solved! in classes/Feature.php public static function getFeaturesForComparison Change: return Db::getInstance()->executeS('SELECT * , COUNT(*) as nbFROM `'._DB_PREFIX_.'feature` fLEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature`LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature`WHERE fp.`id_product` IN ('.$ids.')AND `id_lang` = '.(int)$id_lang.'GROUP BY f.`id_feature`ORDER BY f.position ASC'); Edited September 25, 2014 by wutend (see edit history) 1 Link to comment Share on other sites More sharing options...
Qvixx Posted September 25, 2014 Share Posted September 25, 2014 return Db::getInstance()->executeS(' SELECT * , COUNT(*) as nb FROM `'._DB_PREFIX_.'feature` f LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON f.`id_feature` = fp.`id_feature` LEFT JOIN `'._DB_PREFIX_.'feature_lang` fl ON f.`id_feature` = fl.`id_feature` WHERE fp.`id_product` IN ('.$ids.') AND `id_lang` = '.(int)$id_lang.' GROUP BY f.`id_feature` ORDER BY nb DESC, position ASC I would still prefer this one. It doesn't really make sense to compare features which aren't availlable on all the products. 1 Link to comment Share on other sites More sharing options...
wutend Posted September 26, 2014 Share Posted September 26, 2014 Thanks a lot! It works! Link to comment Share on other sites More sharing options...
frank_jarle Posted September 28, 2014 Author Share Posted September 28, 2014 Sorry for late reply, thank you very much Qvixx. I actually ended up with your second alternative as this suit better. Now its easy to control according to how we arange the order of the Product feature as 80% of all the products uses all the feature. It was a bit frustrating when products showed up with "random" order compared to what we actually set in the BO page, now we are all happy about this :-) 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