Skip to content

Instantly share code, notes, and snippets.

@Mozu-CS
Created February 22, 2016 23:56
Show Gist options
  • Save Mozu-CS/ad0cf7ac6d6565238031 to your computer and use it in GitHub Desktop.
Save Mozu-CS/ad0cf7ac6d6565238031 to your computer and use it in GitHub Desktop.
A snippet for updating an existing property on a Product Type.
public void Update_Property_Value()
{
var propertyResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.Producttypes.ProductTypePropertyResource(_apiContext);
var attributeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.AttributeResource(_apiContext);
var productTypeResource = new Mozu.Api.Resources.Commerce.Catalog.Admin.Attributedefinition.ProductTypeResource(_apiContext);
var attribute = attributeResource.GetAttributeAsync("tenant~color").Result;
var existingProperty = propertyResource.GetPropertyAsync(17, "tenant~color").Result;
existingProperty.VocabularyValues.Add(new AttributeVocabularyValueInProductType()
{
Order = 0,
Value = "Silver",
VocabularyValueDetail = new AttributeVocabularyValue()
{
Content = new AttributeVocabularyValueLocalizedContent()
{
StringValue = "Silver"
},
Value = "Silver",
ValueSequence = 0
}
}
);
var updatedProperty = propertyResource.UpdatePropertyAsync(existingProperty, 17, attribute.AttributeFQN).Result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment