public final class SetAssetDescription extends UpdateActionImpl<T>
See also ProductUpdateCommand.
By variant ID (every variant has a variantId):
withProductHavingAssets(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final LocalizedString newDescription = LocalizedString.ofEnglish("new description"); final ProductVariant masterVariant = product.getMasterData().getStaged().getMasterVariant(); final String assetId = masterVariant.getAssets().get(0).getId(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetAssetDescription.ofVariantId(masterVariant.getId(), assetId, newDescription)); final Product updatedProduct = client().executeBlocking(cmd); final Asset updatedAsset = updatedProduct.getMasterData().getStaged().getMasterVariant().getAssets().get(0); assertThat(updatedAsset.getDescription()).isEqualTo(newDescription); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); return updatedProduct; });
See the test code.
By SKU (attention, SKU is optional field in a variant):
withProductHavingAssets(client(), product -> { assertThat(product.getMasterData().hasStagedChanges()).isFalse(); final LocalizedString newDescription = LocalizedString.ofEnglish("new description"); final ProductVariant masterVariant = product.getMasterData().getStaged().getMasterVariant(); final String assetId = masterVariant.getAssets().get(0).getId(); final ProductUpdateCommand cmd = ProductUpdateCommand.of(product, SetAssetDescription.ofSku(masterVariant.getSku(), assetId, newDescription)); final Product updatedProduct = client().executeBlocking(cmd); final Asset updatedAsset = updatedProduct.getMasterData().getStaged().getMasterVariant().getAssets().get(0); assertThat(updatedAsset.getDescription()).isEqualTo(newDescription); assertThat(updatedProduct.getMasterData().hasStagedChanges()).isTrue(); return updatedProduct; });
See the test code.
getAction
public String getAssetId()
public String getAssetKey()
@Nullable public LocalizedString getDescription()
public static SetAssetDescription ofVariantId(Integer variantId, String assetId, @Nullable LocalizedString description)
public static SetAssetDescription ofVariantId(Integer variantId, String assetId, @Nullable LocalizedString description, @Nullable Boolean staged)
public static SetAssetDescription ofSku(String sku, String assetId, @Nullable LocalizedString description)
public static SetAssetDescription ofSku(String sku, String assetId, @Nullable LocalizedString description, @Nullable Boolean staged)
public static SetAssetDescription ofVariantIdAndAssetKey(Integer variantId, String assetId, @Nullable LocalizedString description)
public static SetAssetDescription ofVariantIdAndAssetKey(Integer variantId, String assetKey, @Nullable LocalizedString description, @Nullable Boolean staged)
public static SetAssetDescription ofSkuAndAssetKey(String sku, String assetId, @Nullable LocalizedString description)
public static SetAssetDescription ofSkuAndAssetKey(String sku, String assetKey, @Nullable LocalizedString description, @Nullable Boolean staged)