Class KeepOtherVariantsSync


  • public class KeepOtherVariantsSync
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> keepOtherVariants​(java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> updateActions, io.sphere.sdk.products.ProductDraft newProductDraft, io.sphere.sdk.products.Product oldProduct)
      Takes product update actions, a new ProductDraft, an old existing Product.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeepOtherVariantsSync

        public KeepOtherVariantsSync()
    • Method Detail

      • keepOtherVariants

        public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> keepOtherVariants​(@Nonnull
                                                                                                                            java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> updateActions,
                                                                                                                            @Nonnull
                                                                                                                            io.sphere.sdk.products.ProductDraft newProductDraft,
                                                                                                                            @Nonnull
                                                                                                                            io.sphere.sdk.products.Product oldProduct)
        Takes product update actions, a new ProductDraft, an old existing Product. This method filters out the update action if it is a RemoveVariant update action.

        Using this method as a BeforeUpdateCallback would prevent the removal of not existing variants in the target product.

        Parameters:
        updateActions - the update action built from comparing newProductDraft and oldProduct.
        newProductDraft - the new ProductDraft being synced.
        oldProduct - the old existing Product.
        Returns:
        the same list of supplied updateActions without RemoveVariant update actions.