commercetools / commercetools-jvm-sdk

The e-commerce SDK from commercetools running on the Java virtual machine.
https://commercetools.github.io/commercetools-jvm-sdk/apidocs/index.html
Other
62 stars 40 forks source link

io.sphere.sdk.products.commands.updateactions.SetAssetKey doesn't work as expected #2205

Closed mim-foryouandyourcustomers closed 1 year ago

mim-foryouandyourcustomers commented 2 years ago

Describe the bug io.sphere.sdk.products.commands.updateactions.SetAssetKey class from java SDK doesn't do what its name suggests. The Update Actions created based on this class delete the Asset rather than updating the Key

To Reproduce Try to update the key of any existing Asset on Product with this code. SetAssetKey.ofVariantId(assetId, productVarianttId, newAssetKey);

Expected behavior The Asset is updated , the new key is newAssetKey

Screenshots/Code snippet The action string is hardcoded in the constructor, however it is wrong. It should be setAssetKey instead of removeAsset

public final class SetAssetKey extends StagedProductUpdateActionImpl<Product> {
  @Nullable
  private final Integer variantId;
  @Nullable
  private final String sku;
  private final String assetId;
  private final String assetKey;

  private SetAssetKey(final String assetId, final String assetKey, @Nullable final Integer variantId, @Nullable final String sku, @Nullable final Boolean staged) {
    super("removeAsset", staged);
    this.assetId = assetId;
    this.assetKey = assetKey;
    this.variantId = variantId;
    this.sku = sku;
  }

Stack information (please complete the following information):

jenschude commented 2 years ago

Moved the issue to the correct repository.

And yes it's a typo. Thanks for the report 👍