Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Any Idea on how to assign shared options whilst creating a variant for a product using code?
Currently I have this which essentially creates the shared options, but once created I would like to assign certain options to a variant
if (existingProduct == null) { merchelloProduct = this.MerchelloServices.ProductService.CreateProductWithKey(product.Name, product.ProductCode, price); merchelloProduct.Available = product.IsPublished; var colour = string.Empty; var size = string.Empty; foreach (var variant in product.ProductVariants) { foreach (var option in options) { if (variant.Colour != null && variant.Colour.Name != colour && option.Name == "Colour" && !option.Choices.Contains(variant.Colour.Sku)) { options.First(x => x.Name == "Colour").Choices.Add(new ProductAttribute(variant.Colour.Name, variant.Colour.Sku)); colour = variant.Colour.Name; } if (variant.Size != null && variant.Size.Name != size && option.Name == "Size" && !option.Choices.Contains(variant.Size.Name)) { options.First(x => x.Name == "Size").Choices.Add(new ProductAttribute(variant.Size.Name, variant.Size.Name)); size = variant.Size.Name; } } var merchelloVariant = this.MerchelloServices.ProductVariantService.CreateProductVariantWithKey(merchelloProduct,) } this.MerchelloServices.ProductOptionService.Save(options); }
if anyone could help that would be appriciated
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Merchello shared product options with variant
Any Idea on how to assign shared options whilst creating a variant for a product using code?
Currently I have this which essentially creates the shared options, but once created I would like to assign certain options to a variant
if anyone could help that would be appriciated
is working on a reply...