Jump to content

Sort attributes drop down menu


Recommended Posts

Can anyone suggest a way of sorting an attributes drop-down menu in any other way but alphabetical?

 

I've got size and colour menus for my products, i would like to choose my own order for the colours, for example; light blue and dark blue next to eachother in the list.

 

The sizes: small, medium, large, xl , xxl in that order, not alphabetical.

 

Hope someone can help?!

Link to comment
Share on other sites

Thanks Mike,

I've made the chanage as below:

 

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

 

it removes the 01. 02. etc, but the order stays alphabetical? If i replace the new code with the original code, the order is correct because of the numbers, any ideas why the new code is not ordering correctly once the numbers are removed?

Link to comment
Share on other sites

Hi eddieblunt,

The point of that modification is to allow you to manually order the attributes using numbers, but that they will not show up on your site as long as you follow that pattern. If you remove those numbers, it renders that part of the code obsolete and won't be of much help when it comes to reordering your attributes.

 

-Mike

Link to comment
Share on other sites

Hi eddieblunt,

The point of that modification is to allow you to manually order the attributes using numbers, but that they will not show up on your site as long as you follow that pattern. If you remove those numbers, it renders that part of the code obsolete and won't be of much help when it comes to reordering your attributes.

 

-Mike

I wasn't very clear.. I've added the numbers to my attributes to get the correct order, the new code removes the numbers on the product page which is correct, but the order is wrong still?
Link to comment
Share on other sites

I wasn't very clear.. I've added the numbers to my attributes to get the correct order, the new code removes the numbers on the product page which is correct, but the order is wrong still?

 

Can you please post a link to one of the product listings where I can check this out for myself?

 

-Mike

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...