/** * Action to add/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param setter the serializer of the attribute * @param value the value to set * @param <T> type of the attribute * @return update action */ public static <T> SetAttribute ofVariantId(final Integer variantId, final NamedAttributeAccess<T> setter, final T value) { return ofVariantId(variantId, setter, value, null); }
/** * Action to add/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param setter the serializer of the attribute * @param value the value to set * @param <T> type of the attribute * @return update action */ public static <T> SetAttribute ofVariantId(final Integer variantId, final NamedAttributeAccess<T> setter, final T value) { return ofVariantId(variantId, setter, value, null); }
/** * Action to add/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param attribute the name and the value of the attribute to update * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final AttributeDraft attribute) { return ofVariantId(variantId, attribute, null); }
/** * Action to add/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param attribute the name and the value of the attribute to update * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final AttributeDraft attribute) { return ofVariantId(variantId, attribute, null); }
/** * Action to add/remove/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param name the name of the attribute, consult the product type to find the name * @param value embedded in an optional the new value of the attribute or an empty Optional to remove the value from the attribute * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final String name, @Nullable final Object value) { return ofVariantId(variantId, name, value, null); }
/** * Action to add/remove/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param name the name of the attribute, consult the product type to find the name * @param value embedded in an optional the new value of the attribute or an empty Optional to remove the value from the attribute * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final String name, @Nullable final JsonNode value) { return ofVariantId(variantId, name, value, null); }
/** * Action to add/remove/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param name the name of the attribute, consult the product type to find the name * @param value embedded in an optional the new value of the attribute or an empty Optional to remove the value from the attribute * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final String name, @Nullable final JsonNode value) { return ofVariantId(variantId, name, value, null); }
/** * Action to add/remove/change a custom attribute. * * @param variantId the variant the attribute value should be set or unset * @param name the name of the attribute, consult the product type to find the name * @param value embedded in an optional the new value of the attribute or an empty Optional to remove the value from the attribute * @return update action */ public static SetAttribute ofVariantId(final Integer variantId, final String name, @Nullable final Object value) { return ofVariantId(variantId, name, value, null); }
public static SetAttribute ofUnsetAttribute(final Integer variantId, final String name, @Nullable final Boolean staged) { return ofVariantId(variantId, name, null, staged); }
public static SetAttribute ofUnsetAttributeForVariantId(final Integer variantId, final String name, @Nullable final Boolean staged) { return ofVariantId(variantId, name, null, staged); }
public static SetAttribute ofUnsetAttributeForVariantId(final Integer variantId, final String name, @Nullable final Boolean staged) { return ofVariantId(variantId, name, null, staged); }
public static SetAttribute of(final Integer variantId, final String name, @Nullable final JsonNode value, @Nullable final Boolean staged) { return ofVariantId(variantId, name, value, staged); }
public static <T> SetAttribute ofUnsetAttribute(final Integer variantId, final NamedAttributeAccess<T> NamedAttributeAccess, @Nullable final Boolean staged) { return ofVariantId(variantId, NamedAttributeAccess.getName(), null, staged); }
public static <T> SetAttribute ofUnsetAttribute(final Integer variantId, final NamedAttributeAccess<T> NamedAttributeAccess, @Nullable final Boolean staged) { return ofVariantId(variantId, NamedAttributeAccess.getName(), null, staged); }
public static <T> SetAttribute of(final Integer variantId, final NamedAttributeAccess<T> setter, final T value, @Nullable final Boolean staged) { return ofVariantId(variantId, AttributeDraft.of(setter, value), staged); }
public static <T> SetAttribute ofVariantId(final Integer variantId, final NamedAttributeAccess<T> setter, final T value, @Nullable final Boolean staged) { return ofVariantId(variantId, AttributeDraft.of(setter, value), staged); }
public static <T> SetAttribute ofUnsetAttributeForVariantId(final Integer variantId, final NamedAttributeAccess<T> NamedAttributeAccess, @Nullable final Boolean staged) { return ofVariantId(variantId, NamedAttributeAccess.getName(), null, staged); }
public static SetAttribute of(final Integer variantId, final AttributeDraft attribute, @Nullable final Boolean staged) { return ofVariantId(variantId, attribute.getName(), attribute.getValue(), staged); }
public static SetAttribute ofVariantId(final Integer variantId, final AttributeDraft attribute, @Nullable final Boolean staged) { return ofVariantId(variantId, attribute.getName(), attribute.getValue(), staged); }
public void setAttributeWithObjectsWithStaged(final Boolean staged) { withProduct(client(), (Product product) -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, asList( SetAttribute.ofSku(sku, "size", "M", staged), SetAttribute.ofVariantId(MASTER_VARIANT_ID, "color", "red", staged) ))); final ProductVariant masterVariant = updatedProduct.getMasterData().getStaged().getMasterVariant(); assertThat(masterVariant.getAttribute("size").getValueAsEnumValue()).isEqualTo(EnumValue.of("M", "M")); assertThat(masterVariant.getAttribute("color").getValueAsLocalizedEnumValue().getKey()).isEqualTo("red"); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isEqualTo(staged); }); }