Skip to Content
author's profile photo Former Member
Former Member

How to sort classification attributes on PDP

Hi Expert,

Can someone guide me how I can sort the classification Attribute on the Product Detail Page.

Thanks Aparna

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jan 25, 2018 at 07:35 AM

    Hi Aparna,

    this suggestion is not tested, but i suggest the following:

    In the impex where you assign classifications attributes to their class (INSERT_UPDATE ClassAttributeAssignment) you can set the position of the attribute. I believe that this should be the Position on the PDP.

     $classCatalogVersion=catalogversion(catalog(id[default='YOURCATALOG']),version[default='1.0'])[unique=true,default='YOURCATALOG:1.0']
     $class=classificationClass(ClassificationClass.code,$classCatalogVersion)[unique=true]
     $attribute=classificationAttribute(code,$classSystemVersion)[unique=true]
     
     INSERT_UPDATE ClassAttributeAssignment;$class;$attribute;position
     ;your-class;your-attribute;1
     ;your-class;your-attribute;2
    
    

    You can do the same in Backoffice under Catalog>Classification Systems>Classifying Categories There you can select the appropriate Category and then you can select the desired classification attribute you wish to edit. Then you can edit the position of the attribute.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2018 at 09:52 PM

    Hi Aparna,

    ' s answer is right for single Classification Category. But if you want to sort by Classification categories; as a work around, you can extend ProductFeatureListPopulator.java and in populate() method it can be sorted with using a default field.

    Or else you can add a new field for sorting. In my case i handled it with using ClassificationData's code;

     @Override
     public void populate(FeatureList source, ProductData target ){
     List<ClassificationData> list = new ArrayList(productData.getClassifications());
     list.sort(Comparator.comparing(ClassificationData::getCode));
     }
    
    
    
    
    
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      In my case both the categories need to be combined to get the sorting based on Position. So I had extended the FeaturePopulator and added position in the FeatureData. After this in ProductPageContorller I combined the FeatureData of all the classifications and sorted with Posotion. This solved my requirement.

      Thanks Aparna

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.