Jump to content

Attribute Order on Product Page


Recommended Posts

Hello.

 

We have a clothing store based on Prestashop 1.6.1.6, and we noticed an issue that we haven't been able to solve.

 

Example:

 

On the product sheet at back office, the combinations are added in the following order:

 

 

image.jpg

 

 

 

But in the product sheet on the front office, the drop down menu shows the combinations (in this case for size, as we only have one color per product) messed up:

 

image.jpg

 

It should show 36, 37, 38, 39...

 

Is there any code we can enter on product.tpl so it shows the attribute in the same order it is added on the product sheet (back office)?

 

I guess this way looks a bit messed up and not clean at all.

 

Thanks in advance for any help.

 

Best regards,

Nuno Costa

Link to comment
Share on other sites

  • 3 weeks later...

Hello Knowband Plugins,

 

Thanks for your help. I'm a bit of a newbie when it comes to code editing so:

 

I found the file Product.php in /public_html/classes and found the following line:

 

    public function getAttributesGroups($id_lang)

 

 

Can you please help me on what I should write to Order by alphabetical/numerical order?

 

Thanks in advance and best regards,

Nuno

Link to comment
Share on other sites

  • 8 months later...
  • 4 months later...

@nunodc
 
To be identical to the admin:
1) Access classes\Product.php
2) Search for getAttributesGroups (approximately line 3489) ...
3) Original code(approximately line 3512):
ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC';
 
Replace with:
ORDER BY ag.`position` ASC, pa.`id_product_attribute` ASC, a.`position` ASC, agl.`name` ASC';
 
4) SAVE and be sure to remove the class_index.php file in the cache folder
 
#Prestashop 1.6.x

Edited by Israel A Santos (see edit history)
  • Like 1
  • Thanks 3
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...

In the latest PrestaShop this could be nicely regulated by selecting positions for the Attributes and Attribute Groups.

The front office then shows the attributes according to their positions.  

To fix this in admin I added the following to the classes/Product.php : first query of getAttributesResume

diff Product.php.modified Product.php
2323,2325d2322
<                 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`
2327,2329c2324
<                 GROUP BY pa.`id_product_attribute`
<                 ORDER BY ag.`position`,a.`position`
<         ');
---
>                 GROUP BY pa.`id_product_attribute`');


 

Edited by Yarick (see edit history)
Link to comment
Share on other sites

  • 1 year later...
On 9/26/2017 at 12:00 AM, Israel A Santos said:

@nunodc
 
To be identical to the admin:
1) Access classes\Product.php
2) Search for getAttributesGroups (approximately line 3489) ...
3) Original code(approximately line 3512):
ORDER BY ag.`position` ASC, a.`position` ASC, agl.`name` ASC';
 
Replace with:
ORDER BY ag.`position` ASC, pa.`id_product_attribute` ASC, a.`position` ASC, agl.`name` ASC';
 
4) SAVE and be sure to remove the class_index.php file in the cache folder
 
#Prestashop 1.6.x

thanks !

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...