cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Programmatically update feature from one classification category to another

rahulverma94
Active Participant
0 Likes
267

Hi Experts,

We are trying to create a job which looks for eligible products and run following logic on them:

1)A product contains two classifying categories Class A and Class B associated to two different classification system versions. 2) Both these Classifying Categories have respective attributes e.g Attribute A and Attribute B 3)My requirement is to fetch the value of Attribute A and set it to Attribute B.

What can be the approach if I start with building my logic on the eligible product model object?

Regards Rahul

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes
 ClassificationService cs = ...
 ProductModel p = ...
 
 // fetch current if necessary
 FeatureList features = cs.getFeatures( p );
 List<Feature> myFeatures = new ArrayList( features.getFeatures() );
 
 if( features.getFeatureByName( "Foo" ) == null )
 {
    // add untyped one 
    myFeatures.add( new Feature( "Foo", Arrays.asList( new FeatureValue( "Bar", null, null ) ), null ) );
    
 }
 // store
 cs.setFeatures( p, new FeatureList( myFeatures ) );