Jump to content

Unable to sort properly in attributes


Recommended Posts

On version 1.5.4.1 under catalog-attributes I am unable to sort the attributes by drag and drop. It physically moves them on screen but when you go back it reverts to the old positions. I looked at db and noticed that the table values dont change. This was fine until the list got bigger. I have now about 30 values and something has stopped it from working

Link to comment
Share on other sites

I did run into that same problem too.

Because I am still testing with 1.5.4.1 it's not too big a problem for me and I was able to help myself with a workaround for now.

 

If you have a csv file with all your combinations in it, then maybe this procedure is of any help to you too until there is a working solution in PS itself.

 

This is what I did:

1. I created an empty combinations csv and imported that with the option to delete all existing combinations checked. This also removes the existing attributes/values!!!

 

2. I then added all required attributes/values via the BO in the exact order in which I want them displayed in the menus and layered navigation block.

 

3. To be sure, I used phpMyAdmin to backup all attributes tables. Just in case I ever have to repeat the procedure.

 

4. Now import all combinations via csv again and leave the option to remove existing combinations UNCHECKED. If you check the option your attributes/values will be deleted again and your sort order will be lost.

 

Now everything is sorted as expected in the front office.

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

That did indeed solve part of the problem.

It does change the sort order within the menus, but it has no influence on the sort order in the layered navigation block.

 

As far as I can see, that is not a problem of the sort order (position) of the attribute values though, but it looks like layered navigation retrieves data ordered by ID instead of ordered by position.

Edited by Toeareg (see edit history)
  • Like 1
Link to comment
Share on other sites

That is the case as far as I am aware, the sort order only affects the front end product page.

 

Hi that as unfortunately not sorted the problem out. I think this is a bug so will look for a solution on the tracker and see if anyone else has logged it

 

Did you check using phpinfo() that the max_input_vars was actually changed, as not all hosts read the php.ini file.

Link to comment
Share on other sites

tried it on local wamp server but nope the problems still persist. One issue I can see in database sometimes the position value is the same for different attributes which I'm guessing shouldn't happen if an array is sorted at the backend

Link to comment
Share on other sites

I have my install on a local wamp server. I was able to move the filters around in Modules>Layered Navigation>Configuration

 

I was able to drag and drop, save, and stay saved. This is for both the Attributes in Catalog>Attributes and Modules>Layered Navigation>Configuration

 

It's very strange that it's not working for you, even after the max_input_vars is changed.

Link to comment
Share on other sites

I have my install on a local wamp server. I was able to move the filters around in Modules>Layered Navigation>Configuration

 

I was able to drag and drop, save, and stay saved. This is for both the Attributes in Catalog>Attributes and Modules>Layered Navigation>Configuration

 

That is not what I meant with "sort order in the layered navigation block" problem.

I have an Attribute "Sizes" which has Values XS,S,M,L,XL,XXL (with ID's 1,2,3,4,5,6 AND positions 0,1,2,3,4,5).

Now my Size select menu shows the attributes in this order AND the layered block Sizes show them in this order too.

 

But if the attribute values are entered as L,M,S,XL,XS,XXL and I want them to show up as XS,S,M,L,XL,XXL then I need to change the positions which gives this matrix:

Val => ID => Position

XS => 5 => 0

S => 3 => 1

M => 2 => 2

L => 1 => 3

XL => 4 => 4

XXL => 6 => 5

 

For the Size select menus this works just fine.

But in my block layered navigation, the attribute values are still shown in ID order, so L,M,S,XL,XS,XXL.

 

That is NOT how this should work.

The block layered navigation should conform to the preferred sort order (positions) just like the menus.

 

**UPDATE**

I made some changes to modules/blocklayered/blocklayered.php (lines 2677 & 2709) to make the sort order of the attribute values work in block layered navigation as well as in the menus.

Line 2677, added a.position in the SELECT clause:

SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group,
a.position, a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group,

 

Line 2709, changed the ORDER BY clause from:

ORDER BY id_attribute_group, id_attribute';

 

to:

ORDER BY id_attribute_group, position';

 

Now all sorting works like it should :)

Edited by Toeareg (see edit history)
  • Like 3
Link to comment
Share on other sites

SOLVED:..thank you, it works...I need to do the same for manufactures and features values, could you please advise what to change? The best - they will be sorted in alphabetical order.... I can't change their positions in BO (is tha a bug?)

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

@Tilki,

 

To get the manufacturers sorted alphabetically open modules/blocklayered/blocklayered.php and look for this string:

GROUP BY p.id_manufacturer

It should be in there twice!

 

Change them both to:

GROUP BY p.id_manufacturer
ORDER BY m.name ASC

 

The features have a position, but I have not needed to use another sorting order yet, so I haven't changed the code for that.

But since it requires joining in another table into the query, that's not some code change I can simply dish up from the top of my head.

If you can live with alphabetical sorting of the features, you can take a shortcut and do the same as for manufacturers:

Change

GROUP BY fv.id_feature_value

 

To:

GROUP BY fv.id_feature_value
ORDER BY fl.name ASC

 

Make sure to keep all code between the enclosing apostrophs.

Hope that works for you.

  • Like 1
Link to comment
Share on other sites

Ok weird I get it on both local wamp and a live server the exact problem. Here's my one response and it doesn't look like yours

 

ok position 6 for attribute 6\r\n

 

That's what I get too when dragging/dropping with Firefox.

But does the DB value not change with it?

Link to comment
Share on other sites

So if you for instance have 30 values for a certain attribute and you drag/drop a value from the top position to the bottom, the correct response for Firebug would be

ok position 29 for attribute xx

and the DB should update all positions for all values because they all move up 1 spot.

 

Can you check if this happens at all or if there is any inconsistancy in the DB update behaviour?

Link to comment
Share on other sites

okay looking at the db I can see that when you move it to the last position. The number assigned for example is 131 yet in the db the values at 134 or 135 still exist and do not change their positions. This doesn't happen on a stock prestashop. May be if you delete a value it messes with their structure

Link to comment
Share on other sites

@johnprest99,

You have my reply message in your box.

 

Just to clarify for the other readers:

I can load and reorder the attributes/values without problems in my test setup. Everything works as it should.

 

So this looks like it's not a Prestashop issue, but rather an installation issue of some kind.

Maybe there is anybody out there who has more knowledge about setting up apache/php/mysql properly?

Link to comment
Share on other sites

okay guys found this to be the problem. It appears along the way (possibly when values are deleted) the max ordering value for example was 136 when there was only 131 products(when moved last position it would always be 131 but of course db has 136 as last entry hence wrong display on screen). Also some attributes have same order value eg 46 three times I spotted in my db. Once I cleared all these up it works as it should. Appears prestashop can not reconfigure itself after deletes possibly

Link to comment
Share on other sites

  • 2 months later...

**UPDATE**

I made some changes to modules/blocklayered/blocklayered.php (lines 2677 & 2709) to make the sort order of the attribute values work in block layered navigation as well as in the menus.

Line 2677, added a.position in the SELECT clause:

SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group,
a.position, a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group,
Line 2709, changed the ORDER BY clause from:

ORDER BY id_attribute_group, id_attribute';
to:

ORDER BY id_attribute_group, position';
Now all sorting works like it should :)

 

 

These work for me. Thank you :lol:

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

  • 7 months later...

Would some one explain how to do this for a n00b like myself that does not know about database editing.

 

I have deleted a few values maybe like 5-10 back in prestashop 1.5 now on 1.6.0.6 i have this problem and have tried everything elese including getting my host to edit my PHP.ini for my VDS.

 

going insane need to arrange my values

 

 

Okay, so have you done anything in your database already. If so, did you make a backup before you did?

Link to comment
Share on other sites

  • 3 weeks later...
  • 4 weeks later...

That is not what I meant with "sort order in the layered navigation block" problem.

I have an Attribute "Sizes" which has Values XS,S,M,L,XL,XXL (with ID's 1,2,3,4,5,6 AND positions 0,1,2,3,4,5).

Now my Size select menu shows the attributes in this order AND the layered block Sizes show them in this order too.

 

But if the attribute values are entered as L,M,S,XL,XS,XXL and I want them to show up as XS,S,M,L,XL,XXL then I need to change the positions which gives this matrix:

Val => ID => Position

XS => 5 => 0

S => 3 => 1

M => 2 => 2

L => 1 => 3

XL => 4 => 4

XXL => 6 => 5

 

For the Size select menus this works just fine.

But in my block layered navigation, the attribute values are still shown in ID order, so L,M,S,XL,XS,XXL.

 

That is NOT how this should work.

The block layered navigation should conform to the preferred sort order (positions) just like the menus.

 

**UPDATE**

I made some changes to modules/blocklayered/blocklayered.php (lines 2677 & 2709) to make the sort order of the attribute values work in block layered navigation as well as in the menus.

Line 2677, added a.position in the SELECT clause:

SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group,
a.position, a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group,
Line 2709, changed the ORDER BY clause from:

ORDER BY id_attribute_group, id_attribute';
to:

ORDER BY id_attribute_group, position';
Now all sorting works like it should :)

 

HI

 excuse me for my bad english but does n work in prestashop 1.6.0.8.  have u sollution?

Link to comment
Share on other sites

  • 3 months later...

I had the same issue on a customer database:

 

Reason was, that several values in a group had the same position values. This can come from a bad import or somehow else..

 

This worked for me: Add a test attribute to this group and delete it right aways. Deletion will clean up positions in the table and the values should be allright again..

 

Hope this helps

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hi, i have prestashop 1.6.0.13 by I can not sort the attributes by alphabetically Name  :(

 

I have many attributes and would like to show in order, I tried to put the line

ORDER BY agl.`id_attribute_group`, al.`name` ASC';

in place of

ORDER BY id_attribute_group, id_attribute ';

but not work!  :(

can someone help me?

Link to comment
Share on other sites

  • 1 year later...

Hi,

I have a problem with sorting product attribute. In BO size is list in order that I added it with combination generator.

But in front ofice attributes are not in same order like in BO.

Problem is that if I choose size which I already add for product before, prestashop place ¨"old" size first and then new created size. But only in FO in BO they are just like they have to be.

Examlpe:

BO 100 x 100cm   (add second)

BO 110 x 110cm    (add first)

 

FO 110 x 110cm  (add first)

FO 100 x 100cm  (add second)

 

 My prestashop version is 1.6.1.4. Can someone please help me with this?

 

post-140755-0-35013500-1492543791_thumb.

post-140755-0-19274300-1492543780_thumb.

post-140755-0-62481800-1492543785_thumb.

Link to comment
Share on other sites

×
×
  • Create New...