on ‎2018 Jul 06 10:25 AM
Hi,
For this range classification feature type, this code always creates the feature value at position 1. Is there a way to specify valueposition 0?
I'm using the classification api. https://help.hybris.com/6.7.0/hcd/8b7a777486691014823afa6e0ed7bb61.html
FeatureList featureList = classificationService.getFeatures(product1);
final Feature feature = featureList.getFeatureByCode("Classification/1.0/Measures_Volts.voltage_range");
println feature
ClassificationAttributeUnitModel classificationAttributeUnit = classificationSystemService.getAttributeUnitForCode(version, "pct");
feature.addValue(new FeatureValue(11,'',classificationAttributeUnit));
classificationService.setFeatures(product1, featureList);
modelService.saveAll(product1)
Request clarification before answering.
Looks like i'll have to use this massively more verbose code unfortunately. But it works!
final ClassificationSystemModel classSystemMean = modelService.create(ClassificationSystemModel.class);
classSystemMean.setId("Classification/1.0");
classSystemVersionMean = modelService.create(ClassificationSystemVersionModel.class);
classSystemVersionMean.setCatalog(classSystemMean);
classSystemVersionMean.setVersion("Classification/1.0");
classClassMean = modelService.create(ClassificationClassModel.class);
classClassMean.setCatalogVersion(classSystemVersionMean);
classClassMean.setCode("Measures_Volts.class");
classPropertyMean = new ClassificationAttributeModel();
classPropertyMean.setCode("thermometer_resolution");
classPropertyMean.setSystemVersion(classSystemVersionMean);
classPropertyAssignmentMean = modelService.create(ClassAttributeAssignmentModel.class);
classPropertyAssignmentMean.setClassificationAttribute(classPropertyMean);
classPropertyAssignmentMean.setClassificationClass(classClassMean);
classPropertyAssignmentMean.setSystemVersion(classSystemVersionMean);
final ProductFeatureModel productFeature = modelService.create(ProductFeatureModel.class);
productFeature.setProduct(product1);
productFeature.setValue(12);
productFeature.setClassificationAttributeAssignment(classPropertyAssignmentMean);
productFeature.setQualifier('Classification/1.0/Measures_Volts.voltage_range');
productFeature.setValuePosition(Integer.valueOf(0));
modelService.save(productFeature);
modelService.saveAll(product1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks but it seems to have no affect on the valueposition column in the table. Still always goes to valueposition 1 instead of 0.
feature.addValue(0, new FeatureValue(11,'',classificationAttributeUnit));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Specify the position using the other Feature.addValue method (which contains an index parameter): https://help.hybris.com/6.7.0/api/commerce-suite/de/hybris/platform/classification/features/Feature....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.