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

remove existing product feature value before updating new one

Former Member
0 Kudos
494

Hello Experts,

I have a task to populate product features with new value and remove the existing feature value. I have used below code :

final FeatureList features = getClassificationService().getFeatures(product);

Feature productfeature = features.getFeatures().get(0);

productfeature.removeAllValues();

productfeature.setValues(my_fvalues);

getClassificationService().setFeature(product, productfeature);

But still I can see old value in product feature values. I believe that's because old value still exist in product feature model.

I am not getting how to remove the old feature before persisting new .

Any help is appreciated !

regards, Sid

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

I achieved through:

 final FeatureList featureList = classificationService.getFeatures(product);

         for (final Feature productFeature : featureList.getFeatures())
         {
             if (productFeature.getClassAttributeAssignment().getClassificationClass().getCatalogVersion().getCatalog().getId()
                     .equalsIgnoreCase(customClassification))
             {
                 productFeature.removeAllValues();
             }
         }

classificationService.replaceFeatures(product, featureList);

Former Member
0 Kudos

Hi ,

I am also facing similar issue , but i did not get your solution in above comment.Can you please eloborate what exact solution did you find for this issue.

Answers (0)