Jump to content

[SOLVED] Sort attributes 1.4.7.0


Recommended Posts

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

post-140755-0-56140900-1329318788_thumb.png

post-140755-0-96320500-1329318896_thumb.png

Link to comment
Share on other sites

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;	}

  • Like 1
Link to comment
Share on other sites

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

  • 5 months later...
×
×
  • Create New...