minh Posted December 29, 2008 Share Posted December 29, 2008 Is it possible to edit the order in which the product Features appears in the Data Sheet?Example: In Admin I have the follow Features availble (in this order):HeightWidthDepthWeightSizeDiameterFormLengthWhen I put in values for Height, Size, Diameter and Form they appear in this order in the Shop:SizeHeightFormDiameterWhy? And is it possible to edit this? Btw, using 1.1 Final. Link to comment Share on other sites More sharing options...
TropischBruin Posted December 29, 2008 Share Posted December 29, 2008 There is no Orderdeditor yet in PrestaShop.I wish there was........ :down: Link to comment Share on other sites More sharing options...
minh Posted December 29, 2008 Author Share Posted December 29, 2008 By the look of it (from my example above), the order of appearance of Features in the Shop is just haphazard. That seems odd, doesn't it? Is there perhaps some way of controlling this by the order in which one introduces the features in Admin? But it doesn't look like that either... Link to comment Share on other sites More sharing options...
michaeld Posted May 12, 2009 Share Posted May 12, 2009 This is a quick hack to organize your features(in de same way you organize your categories):Edit file classes/Product.phpReplace: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product)); } With: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { $result = Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' ORDER BY `name` ASC'); /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } Now your can organize your features by putting the position in front of it, followed by a dotFor example:01.Feature102.Feature2 1 Link to comment Share on other sites More sharing options...
belladict Posted May 13, 2009 Share Posted May 13, 2009 Michaeld, thanks so much, the hack works like a charm Link to comment Share on other sites More sharing options...
enigma32 Posted February 22, 2010 Share Posted February 22, 2010 can someone help.. using this method in classes/product.php function getAttributesGroups to sort attributes and groups with '##.' prefixes, but unable to strip the numbers for display as im not familiar with this whole 'al.' syntax so i dont know what to change 'name' to to strip it Link to comment Share on other sites More sharing options...
enigma32 Posted February 22, 2010 Share Posted February 22, 2010 nevermind.. 'attribute_name' if anybody else is trying to do this Link to comment Share on other sites More sharing options...
Benygh Posted March 19, 2010 Share Posted March 19, 2010 can someone help.. using this method in classes/product.php function getAttributesGroups to sort attributes and groups with '##.' prefixes, but unable to strip the numbers for display as im not familiar with this whole 'al.' syntax so i dont know what to change 'name' to to strip it u can try this module ...http://www.presto-changeo.com/attribute-modules/24-attribute-order.html#idTab5it works fine ...This way doesnt work for me ...it works for the Categories but doesnt work in features ... im using persian version of prestashop ...i think the problem is caused by this but as i said i have no problem with sorting categories with this way ...i tried english titles and persian both, Link to comment Share on other sites More sharing options...
Diemux Posted April 23, 2010 Share Posted April 23, 2010 This no longer works in latest version (1.3.x)I use: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' order by name'); $resultsArray = array(); foreach ($result AS $row) { $row['name'] = Product::hideFeaturePosition($row['name']); $resultsArray[] = $row; } return $resultsArray; } static public function hideFeaturePosition($name) { return preg_replace('/^[0-9]+\./', '', $name); } But no luck. The numbers stay visible. Weird though as I checked with the categories and that is still using the same code (and does work )Any idea's? Link to comment Share on other sites More sharing options...
shopgirl Posted June 12, 2010 Share Posted June 12, 2010 Anyone? I too would like this working for version 1.3. Thanks. Link to comment Share on other sites More sharing options...
justweb Posted June 19, 2010 Share Posted June 19, 2010 Hello,don't work for me. i use 1.3 versionThe prefix appear and filter order doesn't work...my code static public function getFrontFeaturesStatic($id_lang, $id_product) { $result = Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' ORDER BY `name` ASC'); /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } help me please...thx Link to comment Share on other sites More sharing options...
Diemux Posted June 21, 2010 Share Posted June 21, 2010 Works now in 3.0.1.1! Link to comment Share on other sites More sharing options...
Benygh Posted June 21, 2010 Share Posted June 21, 2010 what code did u use ?what file ?! can u explain ? Link to comment Share on other sites More sharing options...
neastea18 Posted July 5, 2010 Share Posted July 5, 2010 I just found another discussion talking about the same problemhttp://www.prestashop.com/forums/viewthread/36968/P0/discussion_generale/gestion_de_lordre_daffichage_des_caracteristiquesHowever, they had a better UI presentation by using:FRUIT.01.AppellationFRUIT.02.OrigineFRUIT.03….AUTO.01.Puissance fiscaleAUTO.02.Nombre de portesAUTO.03….into:FRUITOrigineAppellation[…]AUTOPuissance fiscaleNb de portes[…]Can someone help? Please Link to comment Share on other sites More sharing options...
deniss Posted August 12, 2010 Share Posted August 12, 2010 Here is the code for the 1.3 version, copy the code and replace the old one if you don't want to make mistake (don't forget to back up the old code if something goes wrong)http://www.prestashop.com/forums/viewthread/36968/P15/discussion_generale/gestion_de_lordre_daffichage_des_caracteristiques/ Link to comment Share on other sites More sharing options...
mohsart Posted October 12, 2010 Share Posted October 12, 2010 This no longer works in latest version (1.3.x)I use: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' order by name'); $resultsArray = array(); foreach ($result AS $row) { $row['name'] = Product::hideFeaturePosition($row['name']); $resultsArray[] = $row; } return $resultsArray; } static public function hideFeaturePosition($name) { return preg_replace('/^[0-9]+\./', '', $name); } But no luck. The numbers stay visible. Weird though as I checked with the categories and that is still using the same code (and does work )Any idea's? You didn't change all the codereturn Db::getInstance()->ExecuteS(' is still there/Mats Link to comment Share on other sites More sharing options...
cartcreative Posted December 9, 2010 Share Posted December 9, 2010 Has anybody been able to get this to work on 1.3.2.3 or 1.3.3?I've tried the code from this thread, as well as the code over on the French thread, and its not stripping out the numbers.I really don't even need to have the features listed in a custom order, just listed in the order I entered them in!Can anyone help please? Link to comment Share on other sites More sharing options...
5ummer5 Posted December 9, 2010 Share Posted December 9, 2010 Hi,Im using v.1.3.3 and it worked fine for me. It is just on my localhost at the moment so I hope it doesnt change when I upload it to my main server. Link to comment Share on other sites More sharing options...
cartcreative Posted December 11, 2010 Share Posted December 11, 2010 I've managed to get this working on the front end. Has anyone managed to get the ordering to work in the BO? If so, can you share your code, please? Link to comment Share on other sites More sharing options...
5ummer5 Posted December 11, 2010 Share Posted December 11, 2010 Hi,I think this code will only order the front end and not it the BO. Although im not 100% on that so someone correct me if im wrong! Link to comment Share on other sites More sharing options...
cartcreative Posted December 11, 2010 Share Posted December 11, 2010 Hi 5ummer5 - I realise the code provided is only supposed to be for the front end. On the french thread though, there is mention of modifying admin/tabs/AdminProducts.php (the displayFormFeatures function) to get it to work in the BO too - but no actual code is provided.I was just wondering whether anyone has gotten it to work in the BO and if so, could they provide their code for it. I would save me a hell of a lot of messing about, especially as my php skills suck! Link to comment Share on other sites More sharing options...
5ummer5 Posted December 12, 2010 Share Posted December 12, 2010 Ah ok. That's a shame that there is no code provided on the other thread!I am afraid I haven't attempted this myself as it doesn't bother me too much in the back-end. Link to comment Share on other sites More sharing options...
Pixel Posted January 3, 2011 Share Posted January 3, 2011 You can get the features to sort in the BO (01. 02. etc) by editing the first section of the displayList() function in admin/tabs/AdminFeatures.php so it looks like this (don't replace the whole function with this code - just add the 'Modded' part): /* Report to AdminTab::displayList() for more details */ public function displayList() { global $currentIndex; echo ' table.'&token;='.$this->token.'">'.$this->l('Add feature').' token.'"> '.$this->l('Add feature value').' '.$this->l('Click on the feature name to view its values. Click again to hide them.').' '; $this->displayListHeader(); echo '<input type="hidden" name="groupid" value="0">'; if (!sizeof($this->_list)) echo ''.$this->l('No features found.').''; $irow = 0; // *********** Modded - added to sort features by 01. 02. etc ************ // $tmp = Array(); foreach($this->_list as &$ma) $tmp[] = &$ma["name"]; array_multisort($tmp, $this->_list); // *********** / Modded - added to sort features by 01. 02. etc ************ // foreach ($this->_list AS $tr) This should work with v 1.3.x (tested on v 1.3.5) Link to comment Share on other sites More sharing options...
Eko Teguh Posted January 4, 2011 Share Posted January 4, 2011 Hi, How to sort features on product catalog features tab? I want to sort them by ID.I have looking around on Admin/tab folder, but didn't find where they put the sql to sort. Anyone can help?Thanks Link to comment Share on other sites More sharing options...
Pixel Posted January 27, 2011 Share Posted January 27, 2011 Have another look at the instructions at the beginning of my post (immediately above your post).You need to edit the file and insert the modded code section, then save it. Make sure you use a text editor (not a word-processor) for editing.You also need to rename your features so they have a sort code in front of the name, eg:01.Name of feature02.Name of feature Link to comment Share on other sites More sharing options...
Eko Teguh Posted January 28, 2011 Share Posted January 28, 2011 Thanks pixel. It works!Before, I try to edit modded code at: $tmp[] = &$ma["name"]; and change to $tmp[] = &$ma["id_feature"]; I hope it will sort by id, but didn't work.Before I was afraid the number will be displayed on front office, but it is not. Thanks for the script. It works great for me.PS: But it cause problem on Filter Search. The number is displayed. Still looking script to solve this.Updated: To Remove number on Filter Search, change the code at coremanager/modules/filtersearch/filtersearch.module.php about line 166. '.$group' to '.preg_replace('/^[0-9]+\./', '',$group).' Link to comment Share on other sites More sharing options...
Pixel Posted January 28, 2011 Share Posted January 28, 2011 coremanager/modules/filtersearch/filtersearch.module.php ??Are you using v 1.4?Can't see that file path, even in 1.4 :-) Link to comment Share on other sites More sharing options...
Eko Teguh Posted January 28, 2011 Share Posted January 28, 2011 I'm using 1.3.4.The full path is prestashop/modules/coremanager/modules/filtersearch/fitersearch.module.php. Link to comment Share on other sites More sharing options...
Eko Teguh Posted January 28, 2011 Share Posted January 28, 2011 Anyone can help solve my problems on this thread: http://www.prestashop.com/forums/viewthread/89058/ Link to comment Share on other sites More sharing options...
Pixel Posted January 28, 2011 Share Posted January 28, 2011 Ah, Ok - you have a 3rd-party module called 'filtersearch' in the themes/your theme/modules/ folder.Thanks for explaining that. Link to comment Share on other sites More sharing options...
rastak Posted February 1, 2011 Share Posted February 1, 2011 So could any one tell me where i need to make changes is the BO and FO?Thxn in advance Link to comment Share on other sites More sharing options...
Eko Teguh Posted February 4, 2011 Share Posted February 4, 2011 Hi rastak,The product features, by default sort by name on Front Office, but sort by ID on Back Office. The idea to change the script is to make the same sorting on Front Office and Back Office.You have nothing to change on Front Office, but need to add some script on Back Office. See post #22 above to change script on Back Office.After changed, one thing you have to do is to make some features like usual, but by add numbers (01, 02, etc) in front of the features name. Example: 01.Width, 02.Height, 03.Depth. On Back Office, number will be displayed. But I think it doesn't matter because just the website admin will look into back office.On front office, number and dot (.) will be disappear, because there is default script from prestashop that eliminate the number. Link to comment Share on other sites More sharing options...
rastak Posted February 4, 2011 Share Posted February 4, 2011 Hi ApprenticeThank you, its working.Do you know if there is already code released for the french post where they use FRUIT.01.Apple ? Link to comment Share on other sites More sharing options...
Eko Teguh Posted February 4, 2011 Share Posted February 4, 2011 Do you mean you want to use number and dot (.) on front office?If do so, you have to delete some script on prestashop core (I don't recommend this, but this will be work).Go to prestashop/classes/product.php and go to about line 2339:Original: /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; Then, delete all the script above. Make sure you don't delete } at the end of script (after return $resultsArray;).So Now whatever you write on your feature will displayed as it is. Link to comment Share on other sites More sharing options...
rastak Posted February 4, 2011 Share Posted February 4, 2011 nono, they have a modification where you sort them with another prefix likefruit.01.applefruit.02.Pineapple and this it shows likeFRUIT Apple Pineapple Link to comment Share on other sites More sharing options...
jaymaster Posted February 8, 2011 Share Posted February 8, 2011 Thanks Michaeld! It works Link to comment Share on other sites More sharing options...
nikmagnus Posted March 8, 2011 Share Posted March 8, 2011 Hi there,Can anyone help me re-ordering the feature list isng PS 1.4.0.15?I've looked at the Classes/Product.php and it looks a bit different from what is quoted in earlier posts.Here is the code, could someone help me modify it? /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product); } return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; } Thanks in advance Link to comment Share on other sites More sharing options...
nikmagnus Posted March 13, 2011 Share Posted March 13, 2011 I waited for a while for someone to help me with this issue (reordering the features to my preferred order), but no-one offered to help. So I had another bash at it and I think it works using PS1.4.0.15 (RC6). Hopefully PS will implement changing the orders from the Backend instead.Open and change classes/propduct.php in the prestashop root directory (not in the THEME). Note that this will need to be re-done every time you upgrade.Change (around 2646): public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product); } return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; } to: public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product.' ORDER BY `name`'); } $resultsArray = array(); foreach (self::$_frontFeaturesCache[$id_product.'-'.$id_lang] AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray;; } This does two things: sorts the features by alphabetical, ie 01.feature1, 02.feature2, 03.feature3. Then strips the “01.” from each feature thus restoring the name.For this to work you need to rename your features 01.feature1, 02.feature2, 03.feature3 for this to work. 1 Link to comment Share on other sites More sharing options...
Trove Posted March 23, 2011 Share Posted March 23, 2011 Very usefull post Link to comment Share on other sites More sharing options...
Rams Posted April 16, 2011 Share Posted April 16, 2011 Good work but problem whit compare.In comparison to the numbers listed appear.look here : Link to comment Share on other sites More sharing options...
NemoPS Posted April 16, 2011 Share Posted April 16, 2011 Hi there,rather than just sorting features in back office, is it possibile to code some "filtering" option? I mean, if i sell say cameras, books adn videogames, i'd like to see in backoffice>products>features page just the features list for a specified category. Is it possible? Link to comment Share on other sites More sharing options...
nuttis Posted April 16, 2011 Share Posted April 16, 2011 @rams: Have you find a solution to the compare list problem? I think you need to do some changes in the products-comparisation file. I dont have the knowlage myself to know exactly what to change but i hope someone else can help you as i am curious to know if this is possible to make :-) Link to comment Share on other sites More sharing options...
Rneo Posted May 8, 2011 Share Posted May 8, 2011 Before /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product)); } After /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' order by pf.id_feature'); } Sorting Id Fuetured 1 Link to comment Share on other sites More sharing options...
Pieter Posted May 25, 2011 Share Posted May 25, 2011 HiI use 1.4.1.0 and cannot find a product-comparison.php in classeswhere is this code located?thanksPieter Link to comment Share on other sites More sharing options...
thkalam Posted July 6, 2011 Share Posted July 6, 2011 everything is donejust add a new column on table features and call it sortfeatures then you have to change two filesclasses/product.php & feature.php and just add to sort it by sortfeaturesthis fixes also comparison problem... files will be available sood for bo and fo Link to comment Share on other sites More sharing options...
z72diego Posted September 5, 2011 Share Posted September 5, 2011 Hi, i currently have the 1.4.4.0 version of prestashop. Wich modification i have to make in order to dissapear the numbers from the product compare? Thank you! Link to comment Share on other sites More sharing options...
Zrzek666 Posted October 2, 2011 Share Posted October 2, 2011 Hi, i currently have the 1.4.4.0 version of prestashop. Wich modification i have to make in order to dissapear the numbers from the product compare? Thank you! Change Feature.php in classes from: public static function getFeaturesForComparison($list_ids_product, $id_lang) { $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 nb DESC'); } } to: public static function getFeaturesForComparison($list_ids_product, $id_lang) { $ids = ''; foreach($list_ids_product as $id) $ids .= (int)($id).','; $ids = rtrim($ids, ','); if (empty($ids)) return false; $result = 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 `name` ASC'); $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray;; } } Link to comment Share on other sites More sharing options...
HolyGuyZ Posted October 28, 2011 Share Posted October 28, 2011 Thanks pal. This is what i looking for. It just works perfectly on Prestashop 1.4.4.1. Cheers! Link to comment Share on other sites More sharing options...
sudhakarm1 Posted November 23, 2011 Share Posted November 23, 2011 Is there a way to add sub- features for each features? Like DISPLAY Type: TFT Size: 3.2 Inches Resolution: HVGA, 320 x 480 Pixels Colors: 16 M Link to comment Share on other sites More sharing options...
sudhakarm1 Posted November 23, 2011 Share Posted November 23, 2011 Is there a way to add sub- features for each features? Like DISPLAY Type: TFT Size: 3.2 Inches Resolution: HVGA, 320 x 480 Pixels Colors: 16 M Link to comment Share on other sites More sharing options...
monstrel Posted December 19, 2011 Share Posted December 19, 2011 @nikmagnus & Zrzek666: thanks a lot, it works great on my 1.4.2.5.. Link to comment Share on other sites More sharing options...
hannhimhe Posted December 20, 2011 Share Posted December 20, 2011 Have this been filed as a wanted feature yet? I'm starting to lose count on how many "fixes" I've added by now. Would be nice to have things like this to come with the package. Link to comment Share on other sites More sharing options...
Bradley Clampitt Posted February 8, 2012 Share Posted February 8, 2012 I created a new topic related to this, in a gist what I would like to do is properly override this function using the /override/classes/ folder. Has anyone attempted or succeeded in this? I tried the following code in a file I created /override/classes/Product.php but it doesn't work it still shows the numbers. class Product extends ProductCore { public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product.' order by name ASC'); } /* Added Array Function to remove the Numbers at the beginning of the Feature */ $resultsArray = array(); foreach (self::$_frontFeaturesCache[$id_product.'-'.$id_lang] AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } } Link to comment Share on other sites More sharing options...
Bradley Clampitt Posted February 9, 2012 Share Posted February 9, 2012 I have since made this work as I was trying above... new code listed below. static public function getFrontFeaturesStatic($id_lang, $id_product) { $result=Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' ORDER BY `name` ASC'); $resultsArray = array(); foreach ($result AS $row) { $row['name'] = product::hideFeaturePosition($row['name']); $resultsArray[] = $row; } return $resultsArray; } static public function hideFeaturePosition($name) { return preg_replace('/^[0-9]+./', '', $name); } public function getFrontFeatures($id_lang) { return self::getFrontFeaturesStatic($id_lang, $this->id); } currently using v1.4.4.0 and have not tested it on newer versions but I am sure to do so soon. 4 Link to comment Share on other sites More sharing options...
vayu Posted March 19, 2012 Share Posted March 19, 2012 Good work Bradley! :-) How could this be done in the backend as well, so the order in which the user fills in the Feature input is the same as the frontend? Thanks Vayu Link to comment Share on other sites More sharing options...
icyhot Posted March 21, 2012 Share Posted March 21, 2012 Has anybody tested if all those methods are working with 1.4.7? Link to comment Share on other sites More sharing options...
vayu Posted March 21, 2012 Share Posted March 21, 2012 Hi icyhot. Yes, I have just tested Bradleys code and it works for me in the frontend. :-) Vayu Link to comment Share on other sites More sharing options...
Bradley Clampitt Posted March 21, 2012 Share Posted March 21, 2012 Hey vayu, I have not even messed with the backend area but I would see it as possible but it would be a lot more coding modifications... at least from what I have read about the backend it is setup a little different and made less for customization and more just about working as it is. Just getting back from a couple of trade shows and etc, so hopefully I can start looking at this code again. Link to comment Share on other sites More sharing options...
icyhot Posted March 21, 2012 Share Posted March 21, 2012 Hi icyhot. Yes, I have just tested Bradleys code and it works for me in the frontend. :-) Vayu Thanks vayu and Bradley! But I have a simple question. What do you guys mean by it works on the front side but not on the back side? Isn't the front side what we care? I mean.. to me I don't care as long as the customers don't get confused. I don't mind me (admin) seeing the features in the wrong order. Am I getting something wrong here? or Am I on the right track? Link to comment Share on other sites More sharing options...
icyhot Posted March 21, 2012 Share Posted March 21, 2012 I am so sorry guys.. I created the Product.php file in /override/classes/ with the code posted on post #54 but I got the following error on my front store with a blank background. static public function getFrontFeaturesStatic($id_lang, $id_product) { $result=Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' ORDER BY `name` ASC'); $resultsArray = array(); foreach ($result AS $row) { $row['name'] = product::hideFeaturePosition($row['name']); $resultsArray[] = $row; } return $resultsArray; } static public function hideFeaturePosition($name) { return preg_replace('/^[0-9]+./', '', $name); } public function getFrontFeatures($id_lang) { return self::getFrontFeaturesStatic($id_lang, $this->id); } Link to comment Share on other sites More sharing options...
vayu Posted March 22, 2012 Share Posted March 22, 2012 Hi. I think it is quite relevant for the user experience, that the order in the backend matches the order of the front end. I know it is not as important, but it will make more sence for the unexperinced user if they have the same order in both areas. Bradley, it would be cool if you find a solution for this. :-) Icyhot - I don't know why you get an error. However, what you have posted is not the error, but the actual function. If you go into config->config.inc.php change "display_errors" to true, then it will spit out what error you are getting. Vayu Link to comment Share on other sites More sharing options...
icyhot Posted March 24, 2012 Share Posted March 24, 2012 Hi. I think it is quite relevant for the user experience, that the order in the backend matches the order of the front end. I know it is not as important, but it will make more sence for the unexperinced user if they have the same order in both areas. Bradley, it would be cool if you find a solution for this. :-) Icyhot - I don't know why you get an error. However, what you have posted is not the error, but the actual function. If you go into config->config.inc.php change "display_errors" to true, then it will spit out what error you are getting. Vayu How did you get it to work? Can you teach me? So all you have to do is create the a php file and copy and paste his code in there. and name it Product.php and put it in the /override/classes/ folder.. Am I right? Link to comment Share on other sites More sharing options...
positivezero Posted April 10, 2012 Share Posted April 10, 2012 This one is working. I adapted it from Rneo's post. Just change a little bit at the bottom of the SQL code. I'm working on ver 1.4 Before WHERE pf.id_product = '.(int)$id_product); After WHERE pf.id_product = '.(int)$id_product.' ORDER BY pf.id_feature'); Before /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product)); } After /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' order by pf.id_feature'); } Sorting Id Fuetured Link to comment Share on other sites More sharing options...
Frens Posted April 22, 2012 Share Posted April 22, 2012 Hello, Works fine ! does anyone know whether the product/features can also compare (in alphabetical order) Link to comment Share on other sites More sharing options...
krysavcik Posted April 30, 2012 Share Posted April 30, 2012 This is a quick hack to organize your features(in de same way you organize your categories): Edit file classes/Product.php Replace: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { return Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product)); } With: /* * Select all features for a given language * * @param $id_lang Language id * @return array Array with feature's data */ static public function getFrontFeaturesStatic($id_lang, $id_product) { $result = Db::getInstance()->ExecuteS(' SELECT name, value, pf.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 = '.intval($id_lang).') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.intval($id_lang).') WHERE pf.id_product = '.intval($id_product).' ORDER BY `name` ASC'); /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } Now your can organize your features by putting the position in front of it, followed by a dot For example: 01.Feature1 02.Feature2 Worked perfectly on 1.4.7. Thank you for this awesome trick. Link to comment Share on other sites More sharing options...
yans Posted June 19, 2012 Share Posted June 19, 2012 i did some modification on newer presta, and it works too public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product.' ORDER BY `name` ASC'); /* Modify SQL result */ $resultsArray = array(); foreach (self::$_frontFeaturesCache[$id_product.'-'.$id_lang] AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; } on Feature, set em like this 01.Feature1 02.Feature2 hope this help 2 Link to comment Share on other sites More sharing options...
TWDesign Posted June 19, 2012 Share Posted June 19, 2012 (edited) Need help please. I can add a prefix to each feature in the BO and then list the Product Features in ascending order. BUT I can't figure out how to strip the prefix. e.g. myfeature1, myfeature2 becomes 001.myfeature1, 002myfeature2 etc and this code works fine public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product.' ORDER BY `name` ASC'); } return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; } But I can't figure out how/where to insert this block of code (as mentioned earlier in the thread) /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; When I try this public static function getFrontFeaturesStatic($id_lang, $id_product) { if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) { self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT name, value, pf.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)$id_lang.') LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = pf.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') WHERE pf.id_product = '.(int)$id_product.' ORDER BY `name` ASC'); /* Modify SQL result */ $resultsArray = array(); foreach ($result AS $row) { $row['name'] = preg_replace('/^[0-9]+\./', '', $row['name']); $resultsArray[] = $row; } return $resultsArray; } return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; } it just "kills" the features tab entirely. Nothing shows for that tab. * PLUS * how can I also trim feature prefix on the Product Compare page? I'd rather not fiddle with adding extra database columns if possible. I am using PSvers 1.4.7.0 Edited June 19, 2012 by TWDesign (see edit history) Link to comment Share on other sites More sharing options...
TWDesign Posted June 20, 2012 Share Posted June 20, 2012 I am removing the "sort prefix" with jQuery for now, but I would like to know a server-side solution for this. Link to comment Share on other sites More sharing options...
yans Posted June 21, 2012 Share Posted June 21, 2012 I am removing the "sort prefix" with jQuery for now, but I would like to know a server-side solution for this. look into my code, above your post, hope that help Link to comment Share on other sites More sharing options...
TWDesign Posted June 22, 2012 Share Posted June 22, 2012 look into my code, above your post, hope that help Oh, thank you. I didnt notice those updates. ! Before I try, can I ask - does this fix the problem for BOTH the product page and the product comparison page? I need to list the features in a consistent order for both. Link to comment Share on other sites More sharing options...
tdr170 Posted June 22, 2012 Share Posted June 22, 2012 I would like to have the attributes arranged in the order of size Small, Medium, Large, Xlarge but cannot get it to work. The code above does not seem to work for attributes any ideas as the prefixes are not removed. 01.small = 01.small and so on I could easily just have 1,2,3,4 and put them in order but thats just not what I want. Seems like a real oversite on the Prestashop side. Link to comment Share on other sites More sharing options...
TWDesign Posted June 22, 2012 Share Posted June 22, 2012 I would like to have the attributes arranged in the order of size Small, Medium, Large, Xlarge but cannot get it to work. The code above does not seem to work for attributes any ideas as the prefixes are not removed. 01.small = 01.small and so on I could easily just have 1,2,3,4 and put them in order but thats just not what I want. Seems like a real oversite on the Prestashop side. This thread is about Features, not Attributes. Two entirely different animals. However, I can recommend the PrestoChangeo Attributes Wizard Module which does exactly what you want, and more. Be aware though, that installing it DOES require quite a bit of core file modification, which could be an issue come upgrade time. Link to comment Share on other sites More sharing options...
tdr170 Posted June 22, 2012 Share Posted June 22, 2012 This thread is about Features, not Attributes. Two entirely different animals. However, I can recommend the PrestoChangeo Attributes Wizard Module which does exactly what you want, and more. Be aware though, that installing it DOES require quite a bit of core file modification, which could be an issue come upgrade time. Well aware of what this thread is about. Thanks anyway!!! Link to comment Share on other sites More sharing options...
TWDesign Posted June 23, 2012 Share Posted June 23, 2012 Does this fix the problem for BOTH the product page and the product comparison page? I need to list the features in a consistent order for both. Link to comment Share on other sites More sharing options...
yans Posted June 25, 2012 Share Posted June 25, 2012 nope, that's only to modify product page you'll need to modify this function too public static function getFeaturesForComparison same code, just need to copy paste the code there Link to comment Share on other sites More sharing options...
TWDesign Posted June 26, 2012 Share Posted June 26, 2012 nope, that's only to modify product page you'll need to modify this function too public static function getFeaturesForComparison same code, just need to copy paste the code there Thank you so much. Link to comment Share on other sites More sharing options...
sakrafanas Posted September 14, 2012 Share Posted September 14, 2012 (edited) how to remove numbers 01,02,03... from block layered navigation module? Edited September 15, 2012 by sakrafanas (see edit history) Link to comment Share on other sites More sharing options...
Mr.Pink Posted November 26, 2012 Share Posted November 26, 2012 (edited) . Edited July 30, 2013 by Mr.Pink (see edit history) Link to comment Share on other sites More sharing options...
YellowDuck Posted July 15, 2015 Share Posted July 15, 2015 Good idea, but don't work on 1.6.1(( Link to comment Share on other sites More sharing options...
sneakypete92 Posted July 26, 2015 Share Posted July 26, 2015 Can anyone assist on solving this original problem for PS 1.6 ? Link to comment Share on other sites More sharing options...
sneakypete92 Posted July 26, 2015 Share Posted July 26, 2015 Disregard previous post - I've worked out my issue. The problem was that in my database, in table "ps_features", the "position" values were all incorrect. The solution is to go into the table "ps_features_lang" and map out the names of your features and the "id_feature". Then, go back to the table "ps_features" and change the "position" values so that they are in the correct order. Link to comment Share on other sites More sharing options...
pcFrogRo Posted January 4, 2016 Share Posted January 4, 2016 Hello every one, I have a little problem. I can;t find how to fix feature products problem. I added in an specificaly order all featured, but now always i find them random. Is hard to search between them when i add features to a product. Here i got a printscreen: http://prntscr.com/9lw9ot - i want to keep the ID order, but somehow, they change the order and dublicated the position number 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