roco Posted March 15, 2013 Share Posted March 15, 2013 Good afternoon. On the page that the user compares the products, how do I show the features of the products ordering them by id Thank you in advance anyone who can help. Link to comment Share on other sites More sharing options...
PascalVG Posted March 17, 2013 Share Posted March 17, 2013 You could try this: Edit file /classes/CompareProduct.php, and find function: public static function getCompareProducts($id_compare) { $results = Db::getInstance()->executeS(' SELECT DISTINCT `id_product` FROM `'._DB_PREFIX_.'compare` c LEFT JOIN `'._DB_PREFIX_.'compare_product` cp ON (cp.`id_compare` = c.`id_compare`) WHERE cp.`id_compare` = '.(int)($id_compare).' ORDER BY id_product'); // add this (don't forget the period!) $compareProducts = null; ... } Add the red part to it, and see if this works (don't forget the "." at the beginning of the addition!) Not sure if this is enough, or that we need to change addCompareProduct() as well. try this first :-) Pascal Hope this helps, Pascal Link to comment Share on other sites More sharing options...
doubleD Posted April 8, 2013 Share Posted April 8, 2013 (edited) Hi, Open classes/Feature.php Find public static function getFeaturesForComparison Replace ORDER BY nb DESC with ORDER BY f.id_feature ASC here: 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 f.`id_feature` ASC '); If you want features order as set in the Back Office / Product page use ORDER BY f.position ASC instead Edited April 8, 2013 by doubleD (see edit history) 3 Link to comment Share on other sites More sharing options...
MissLili Posted June 12, 2014 Share Posted June 12, 2014 thats's awesome! exactly what I was looking for! Maybe this should be an option that we can set somewhere in the prestashop BO? Aniway thanks! Link to comment Share on other sites More sharing options...
MissLili Posted June 12, 2014 Share Posted June 12, 2014 (edited) *deleted* Edited June 12, 2014 by niclap (see edit history) Link to comment Share on other sites More sharing options...
carejung Posted October 14, 2014 Share Posted October 14, 2014 Thank you. Worked perfectly for me in prestashop 1.6.0.9. You can try the query directly on you db and you will see the right ordered result. Link to comment Share on other sites More sharing options...
gPowerHost Posted October 27, 2014 Share Posted October 27, 2014 Thanks! I'm sure loving the PrestaShop way.For any newbies, to extend the core and have your changes survive an upgrade, in PS 1.6.0.9 simply create this file in this location (to have features in the front end obey the sort order as set in the backend):Create a new file (or if one exists, merge this function, getFeaturesForComparison, or add it) override/classes/Feature.php <?php /* * 2007-2014 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA * * */ class Feature extends FeatureCore { public static function getFeaturesForComparison($list_ids_product, $id_lang) { if (!Feature::isFeatureActive()) return false; $ids = ''; foreach ($list_ids_product as $id) $ids .= (int)$id.','; $ids = rtrim($ids, ','); if (empty($ids)) return false; 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 f.position ASC '); } } ?> This way your changes will survive an upgrade and you will only have to monitor if the original function: "getFeaturesForComparison" in classes/Feature.php for any rare changes (in which case you will have to do a merge, or just copy the new function as modified and search and replace:ORDER BY nb DESC WITH: ORDER BY f.position ASC Voila! Link to comment Share on other sites More sharing options...
ALMAJ Posted January 11, 2015 Share Posted January 11, 2015 This worked well for ordering product feature!but how to order The product Feature Values as set in the Back Office / Product page? thanks again Link to comment Share on other sites More sharing options...
gadnis Posted January 19, 2016 Share Posted January 19, 2016 If you want features ordered by name, use: ORDER BY fl.name ASC 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