//if product does exist
variantProduct.set("isVirtual", "N");
variantProduct.set("isVariant", "Y");
variantProduct.set("primaryProductCategoryId", null);
//update entry
variantProduct.store();
}
if (variantProductExists) {
// Since the variant product is already a variant, first of all we remove the old features
// and the associations of type PRODUCT_VARIANT: a given product can be a variant of only one product.
delegator.removeByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", variantProductId,