akeneo / pim-community-dev

[Community Development Repository] The open source Product Information Management (PIM)
http://www.akeneo.com
Other
951 stars 516 forks source link

Attribute Group Order not respected #5016

Closed julienanquetil closed 8 years ago

julienanquetil commented 8 years ago

I'm reporting a Bug

I think there is a bug in the product edit form When you order your group attribute in a specific order for example : attribute order

the order is Ok in DB (mysql in my case) but when you go to create / edit a product, attributes group are not in the right Order : pef

I check in the /configuration/attribute-group/rest and data are OK the sort order is right there

I got in in 1.6.2 and also on demo.akeneo.com

Thanks

nidup commented 8 years ago

Hi @julienanquetil !

Thank you for raising this issue, we noticed it, we tested and it was working fine in 1.5 but not anymore in 1.6.

You can claim this new badge http://badger.akeneo.com/badge/57861115-69f6-11e6-92dc-d60437e930cf :wink:

Are you interested to contribute a fix for this issue on the 1.6 branch? We'll be happy to help you, to review the fix and to merge it.

Thank you!

julienanquetil commented 8 years ago

Hi @nidup,

for sure if I can help i'll do it. I'm trying to understand where the "wrong thing" where... (but never take a look into akeneo code before 1.6 really..)

If you have any advice i'll take it.

And got also an error with the badger (always try again... with this one and the slack one)

grena commented 8 years ago

@julienanquetil Woops, fixed sorry. You can now claim your badges! :bug:

julienanquetil commented 8 years ago

@grena got an htpasswd now ahah

grena commented 8 years ago

@julienanquetil Sorry yes, you should use an http link, not https, I've created an issue, I hotfix it this weekend =)

nidup commented 8 years ago

Hi @julienanquetil !

I took a very quick look at the issue, I think that the following change will fix it,

diff --git a/src/Pim/Bundle/EnrichBundle/Resources/public/js/form/common/attributes.js b/src/Pim/Bundle/EnrichBundle/Resources/public/js/form/common/attributes.js
index 2c057bb..cf6ee0b 100644
--- a/src/Pim/Bundle/EnrichBundle/Resources/public/js/form/common/attributes.js
+++ b/src/Pim/Bundle/EnrichBundle/Resources/public/js/form/common/attributes.js
@@ -207,7 +207,7 @@ define(
                 promises.push(AttributeGroupManager.getAttributeGroupsForObject(object)
                     .then(function (attributeGroups) {
                         this.getExtension('attribute-group-selector').setElements(
-                            _.indexBy(_.sortBy(attributeGroups, 'sortOrder'), 'code')
+                            _.indexBy(_.sortBy(attributeGroups, 'sort_order'), 'code')
                         );
                     }.bind(this))
                 );

This is due to a change in our structured format during the 1.6 developments (now all these keys are snake case not camel case), https://github.com/akeneo/pim-community-dev/commit/c16ce18a52adc164e7ef9a45b0a8934718756b56#diff-2aa0460734718243b6b89a37b37a21ecL48

Don't hesitate to open a pull request on the 1.6 branch, I'll be glad to review, double check and merge it :tada:

Thanks!

julienanquetil commented 8 years ago

I have a chat with @juliensnz this morning about it and that the "result" ;) i make a PR #5020 . Thanks

nidup commented 8 years ago

Merged! Thanks for the fix, it will be available in the upcoming v1.6.3 :tada:

Don't hesitate to open any other issue you could encounter or to write other pull requests to help us to fix known issues on the community edition https://github.com/akeneo/pim-community-dev/projects/1

Have a good day!