public final class RemoveImage extends UpdateActionImpl<T>
See also ProductUpdateCommand.
By variant ID (every variant has a variantId):
final Image image = createExternalImage(); withUpdateableProduct(client(), product -> { final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofVariantId(MASTER_VARIANT_ID, image))); assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image)); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, RemoveImage.ofVariantId(MASTER_VARIANT_ID, image))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0); return updatedProduct; });
See the test code.
By SKU (attention, SKU is optional field in a variant):
final Image image = createExternalImage(); withUpdateableProduct(client(), product -> { final String sku = product.getMasterData().getStaged().getMasterVariant().getSku(); final Product productWithImage = client().executeBlocking(ProductUpdateCommand.of(product, AddExternalImage.ofSku(sku, image))); assertThat(productWithImage.getMasterData().getStaged().getMasterVariant().getImages()).isEqualTo(asList(image)); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productWithImage, RemoveImage.ofSku(sku, image))); assertThat(updatedProduct.getMasterData().getStaged().getMasterVariant().getImages()).hasSize(0); return updatedProduct; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getImageUrl() |
String |
getSku() |
Integer |
getVariantId() |
Boolean |
isStaged() |
static RemoveImage |
of(Image image,
Integer variantId) |
static RemoveImage |
of(String imageUrl,
Integer variantId) |
static RemoveImage |
ofSku(String sku,
Image image) |
static RemoveImage |
ofSku(String sku,
Image image,
Boolean staged) |
static RemoveImage |
ofSku(String sku,
String imageUrl) |
static RemoveImage |
ofSku(String sku,
String imageUrl,
Boolean staged) |
static RemoveImage |
ofVariantId(Integer variantId,
Image image) |
static RemoveImage |
ofVariantId(Integer variantId,
Image image,
Boolean staged) |
static RemoveImage |
ofVariantId(Integer variantId,
String imageUrl) |
static RemoveImage |
ofVariantId(Integer variantId,
String imageUrl,
Boolean staged) |
getAction
public String getImageUrl()
public static RemoveImage of(Image image, Integer variantId)
public static RemoveImage of(String imageUrl, Integer variantId)
public static RemoveImage ofVariantId(Integer variantId, Image image)
public static RemoveImage ofVariantId(Integer variantId, String imageUrl)
public static RemoveImage ofVariantId(Integer variantId, Image image, @Nullable Boolean staged)
public static RemoveImage ofVariantId(Integer variantId, String imageUrl, @Nullable Boolean staged)
public static RemoveImage ofSku(String sku, Image image)
public static RemoveImage ofSku(String sku, Image image, @Nullable Boolean staged)
public static RemoveImage ofSku(String sku, String imageUrl)
public static RemoveImage ofSku(String sku, String imageUrl, @Nullable Boolean staged)