List<GenericValue> variants = EntityUtil.getRelated("AssocProduct", variantAssocs);
for (GenericValue variant: variants) {
// get the selectable features for the variant
List<GenericValue> productFeatureAndAppls = variant.getRelated("ProductFeatureAndAppl", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "productFeatureApplTypeId", "STANDARD_FEATURE"), null);
for (GenericValue productFeatureAndAppl: productFeatureAndAppls) {
GenericPK productFeatureApplPK = delegator.makePK("ProductFeatureAppl");
productFeatureApplPK.setPKFields(productFeatureAndAppl);
delegator.removeByPrimaryKey(productFeatureApplPK);
}
}
List<GenericValue> productFeatureAndAppls = product.getRelated("ProductFeatureAndAppl", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"), null);
for (GenericValue productFeatureAndAppl: productFeatureAndAppls) {
GenericPK productFeatureApplPK = delegator.makePK("ProductFeatureAppl");
productFeatureApplPK.setPKFields(productFeatureAndAppl);
delegator.removeByPrimaryKey(productFeatureApplPK);
}
} catch (GenericEntityException e) {
String errMsg = "Error creating new virtual product from variant products: " + e.toString();
request.setAttribute("_ERROR_MESSAGE_", errMsg);