andrej981 Posted February 15, 2012 Share Posted February 15, 2012 Hi I need your help. I dont know how to sort attributes in prestashop 1.4.7.0. I wont to sort attributes with "01.", "02.", ... but i dont know how can I hide this "01.", "02.", ... from the Attribute name at product page. I dont care if this "01.", "02.", ... is visible on cart, invoice... So please if some one know how to do it please help me. Picture 1 show what i wont. Picture 2 show what I have nov Br Andrej Link to comment Share on other sites More sharing options...
tomerg3 Posted February 15, 2012 Share Posted February 15, 2012 Check out http://www.presto-changeo.com/en/attribute-modules/24-attribute-order.html Link to comment Share on other sites More sharing options...
andrej981 Posted February 15, 2012 Author Share Posted February 15, 2012 If I buy this module can I sort attributes once? Or I have to sort attributes for each product? I have to sort colors. Allmost all my products have same colors in same order. Link to comment Share on other sites More sharing options...
tomerg3 Posted February 15, 2012 Share Posted February 15, 2012 You sort it once, it will apply to all the products that use those attributes. Link to comment Share on other sites More sharing options...
andrej981 Posted February 17, 2012 Author Share Posted February 17, 2012 Does enyone know how to do this without buying this module? Link to comment Share on other sites More sharing options...
andrej981 Posted February 24, 2012 Author Share Posted February 24, 2012 SOLVED I solved this problem. Here is how to : In this way you can sort products attributes with numbers. Attributes will be displayed at product page like you added them in BO. And numbers for sort will not be displayed at the product page. This work in prestashop 1.4.7.0. Like this: 01. Red 02. black 03. ..... You have to change file classes/product.php Find and replace: public function getAttributesGroups($id_lang) { return Db::getInstance()->ExecuteS(' SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE pa.`id_product` = '.(int)($this->id).' AND al.`id_lang` = '.(int)($id_lang).' AND agl.`id_lang` = '.(int)($id_lang).' ORDER BY agl.`public_name`, al.`name`'); } WITH THIS: public function getAttributesGroups($id_lang) { $result = Db::getInstance()->ExecuteS(' SELECT ag.`id_attribute_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE pa.`id_product` = '.intval($this->id).' AND al.`id_lang` = '.intval($id_lang).' AND agl.`id_lang` = '.intval($id_lang).' ORDER BY agl.`name`, al.`name`, pa.`id_product_attribute`'); /* Modify SQL result - hide 01. 02. */ $resultsArray = array(); foreach ($result AS $row) { $row['attribute_name'] = preg_replace('/^[0-9]+\./', '', $row['attribute_name']); $resultsArray[] = $row; } return $resultsArray; } 1 Link to comment Share on other sites More sharing options...
Mike Kranzler Posted February 24, 2012 Share Posted February 24, 2012 Thanks Andrej! I'll go ahead and mark this thread as solved for you. Happy Friday! -Mike Link to comment Share on other sites More sharing options...
patrmich Posted February 28, 2012 Share Posted February 28, 2012 Hi andrej981, I have tried to use your method. But on the product page, I can see the following error message : Notice: Undefined index: is_color_group in /.../www.myshop.com/htdocs/controllers/ProductController.php on line 290 Notice: Undefined index: ean13 in /.../www.myshop.com/htdocs/controllers/ProductController.php on line 309 Notice: Undefined index: ean13 in /.../www.myshop.com/htdocs/controllers/ProductController.php on line 309 Notice: Undefined index: ean13 in /.../www.myshop.com/htdocs/controllers/ProductController.php on line 309 Have you got any idea on the way to solve the matter ? Thnak you in advance for nay help. Patrick Link to comment Share on other sites More sharing options...
TextOnAFlatScreen Posted August 23, 2012 Share Posted August 23, 2012 I've tried andre's solution on PrestaShop v.1.4.8.2. The numbers don't show up, but the order of the attributes still don't change Link to comment Share on other sites More sharing options...
Recommended Posts