DanielStrongbrand Posted June 6 Share Posted June 6 Hello Prestashop Forum, We have a PS site that deals in food items, and it's important that the nutritional information is displayed. So we added a Feature for Nutritional Values, and added all the values via that. There's 9 values in total, and they should be displayed in that order, starting from 1, going all the way down to 9. However, Prestashop seems to automatically alphabeticize Feature Values. So the features are displayed correctly, only the ordering is messed up. It does not seem to be a theme thing either, as the standard PS theme also orders multiple Feature Values in alphabetical order. We've tried changing to custom values or predefined values, but this does not seem to make a difference. In the backend of the shop, in the product itself, it seems to be ordered in the way we imported it. But on the front end, it orders them in an alphabetical way. I've already tried fiddling around with the classes/Product.php file and a few others, but nothing seems to do the trick. Hopefully someone here can help us along a little bit. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 6 Share Posted June 6 Hi, how do you want to sort string like number values especially when you have only numbers and some with g? Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 6 Author Share Posted June 6 Just now, Prestashop Addict said: Hi, how do you want to sort string like number values especially when you have only numbers and some with g? Hi, it's not just number values. The word in front of the numbers are part of the value. The Feature is called Voedingswaardes, meaning Nutritional Values in Dutch. There's multiple feature values, and in the backend they are showing in the right order. However, in the front end, they show up in the different order. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 7 Share Posted June 7 Ok you want to display them in ID order? Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 7 Author Share Posted June 7 55 minutes ago, Prestashop Addict said: Ok you want to display them in ID order? Yes exactly, I want to display them in the front end the way they're ordered in the back end also. Is this easily done by editing a php file, or will some changes to the values themselves have to be made? Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 7 Share Posted June 7 2 solutions override php class Feature.php method getFeatures() (php skill needed) override theme template product-details.tpl (smarty and php skill need) Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 7 Author Share Posted June 7 8 minutes ago, Prestashop Addict said: 2 solutions override php class Feature.php method getFeatures() (php skill needed) override theme template product-details.tpl (smarty and php skill need) The first sounds better, as this function should stay present if a switch in templates does ever happen. However, should any PHP changes regarding the ordering of the values not take place in the FeatureValue.php instead of the Feature.php? Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 7 Share Posted June 7 If you don't have skills on php and Prestashop override, I recommend you to ask a professional, this modification is not expensive 😉 Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 7 Author Share Posted June 7 5 minutes ago, Prestashop Addict said: If you don't have skills on php and Prestashop override, I recommend you to ask a professional, this modification is not expensive 😉 Don't worry, I do have some skill in PHP and overrides. It's just that the Feature.php doesn't call to any of the database tables that makes use of the Feature values or their IDs. I do believe you that it may need to be changed there, but a simple point in the right direction could make the difference. To my knowledge, the only tables that contains the IDs of these feature values are feature_value and feature_value_lang. The values all have an ID in the backend that matches the one in the Database, so it should be possible to order them in such a manner. But when looking through Feature.php, I cannot find anything that calls upon feature_value_lang in any way, while FeatureValue.php does, quite obiously even. public static function getFeatureValuesWithLang($idLang, $idFeature, $custom = false) { return Db::getInstance()->executeS(' SELECT * FROM `' . _DB_PREFIX_ . 'feature_value` v LEFT JOIN `' . _DB_PREFIX_ . 'feature_value_lang` vl ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = ' . (int) $idLang . ') WHERE v.`id_feature` = ' . (int) $idFeature . ' ' . (!$custom ? 'AND (v.`custom` IS NULL OR v.`custom` = 0)' : '') . ' ORDER BY vl.`value` ASC '); } When I change the ORDER BY at the end and place the file in the override folder, it doesn't change anything. It does notice the override, as the file appears in the override section of the backend, but it unfortunately doesn't seem to change much. There must be a small change I'm still missing here. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 7 Share Posted June 7 Did you try to change order of features entries in admin Attributes & Features? Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 7 Author Share Posted June 7 4 minutes ago, Prestashop Addict said: Did you try to change order of features entries in admin Attributes & Features? I did, they're sorted by ID in the backend. However there does not seem to be a function to drag and drop for feature values, as there is for features themselves. In the features overview you can edit the position, but in the value overview, this simply seems to be done by either ID or Name, and either Ascending or Descending. Not sure if it has much impact on the front end, though. I'm a little stumped, because it almost seems that everywhere the order of the values is correct, except when it gets loaded onto the front end of the shop. Link to comment Share on other sites More sharing options...
Prestashop Addict Posted June 7 Share Posted June 7 (edited) Works fine for me Order of features, you can change it In BO product sheet PS displays sorted by name But in front my order is good but you cannot sort by values 😞 Edited June 7 by Prestashop Addict (see edit history) Link to comment Share on other sites More sharing options...
DanielStrongbrand Posted June 10 Author Share Posted June 10 On 6/7/2024 at 4:23 PM, Prestashop Addict said: Works fine for me Order of features, you can change it In BO product sheet PS displays sorted by name But in front my order is good but you cannot sort by values 😞 I see, the feature sorting indeed works as intended, but the feature value sorting is unfortunately not there... I'm going to try and find out if it's possible in some other way, but thank you for your help so far at least! 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