public final class SetProductPriceCustomField extends SetCustomFieldBase<Product>
See also ProductUpdateCommand.
withUpdateableType(client(), type -> { withUpdateablePricedProduct(client(), product -> { final String priceId = getFirstPrice(product).getId(); final UpdateAction<Product> updateAction = SetProductPriceCustomType. ofTypeIdAndObjects(type.getId(), STRING_FIELD_NAME, "a value", priceId); final ProductUpdateCommand productUpdateCommand = ProductUpdateCommand.of(product, updateAction); final Product updatedProduct = client().executeBlocking(productUpdateCommand); final Price price = getFirstPrice(updatedProduct); assertThat(price.getCustom().getFieldAsString(STRING_FIELD_NAME)) .isEqualTo("a value"); final Product updated2 = client().executeBlocking(ProductUpdateCommand.of(updatedProduct, SetProductPriceCustomField.ofObject(STRING_FIELD_NAME, "a new value", priceId))); assertThat(getFirstPrice(updated2).getCustom().getFieldAsString(STRING_FIELD_NAME)) .isEqualTo("a new value"); return updated2; }); return type; });
See the test code.
Custom
Modifier and Type | Method and Description |
---|---|
String |
getPriceId() |
Boolean |
getStaged() |
static SetProductPriceCustomField |
ofJson(String name,
com.fasterxml.jackson.databind.JsonNode value,
String priceId) |
static SetProductPriceCustomField |
ofJson(String name,
com.fasterxml.jackson.databind.JsonNode value,
String priceId,
Boolean staged) |
static SetProductPriceCustomField |
ofObject(String name,
Object value,
String priceId) |
static SetProductPriceCustomField |
ofObject(String name,
Object value,
String priceId,
Boolean staged) |
static SetProductPriceCustomField |
ofUnset(String name,
String priceId) |
static SetProductPriceCustomField |
ofUnset(String name,
String priceId,
Boolean staged) |
getName, getValue
getAction
public static SetProductPriceCustomField ofJson(String name, com.fasterxml.jackson.databind.JsonNode value, String priceId)
public static SetProductPriceCustomField ofJson(String name, com.fasterxml.jackson.databind.JsonNode value, String priceId, @Nullable Boolean staged)
public static SetProductPriceCustomField ofObject(String name, Object value, String priceId)
public static SetProductPriceCustomField ofObject(String name, Object value, String priceId, @Nullable Boolean staged)
public static SetProductPriceCustomField ofUnset(String name, String priceId)
public static SetProductPriceCustomField ofUnset(String name, String priceId, @Nullable Boolean staged)
public String getPriceId()