public final class ProductUpdateActionUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildAddToCategoryUpdateActions(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
Set of Category References of a ProductDraft and a Product. |
static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildChangeMasterVariantUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct,
ProductSyncOptions syncOptions)
Create update action, if
newProduct has #masterVariant#key different than oldProduct
staged #masterVariant#key. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildChangeNameUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString names of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildChangeSlugUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString slugs of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildPublishUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the 'published' field of a
ProductDraft and a Product and accordingly returns
a Publish or Unpublish update action as a result in an Optional. |
static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildRemoveFromCategoryUpdateActions(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
Set of Category References of a ProductDraft and a Product. |
static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetCategoryOrderHintUpdateActions(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
CategoryOrderHints of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetDescriptionUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString descriptions of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetMetaDescriptionUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString meta descriptions of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetMetaKeywordsUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString meta keywordss of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetMetaTitleUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
LocalizedString meta titles of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildSetSearchKeywordsUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
SearchKeywords of a ProductDraft and a Product. |
static java.util.Optional<io.sphere.sdk.products.commands.updateactions.SetTaxCategory> |
buildSetTaxCategoryUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
TaxCategory references of an old Product and
new ProductDraft. |
static java.util.Optional<io.sphere.sdk.products.commands.updateactions.TransitionState> |
buildTransitionStateUpdateAction(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct)
Compares the
State references of an old Product and
new ProductDraft. |
static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> |
buildVariantsUpdateActions(io.sphere.sdk.products.Product oldProduct,
io.sphere.sdk.products.ProductDraft newProduct,
ProductSyncOptions syncOptions,
java.util.Map<java.lang.String,AttributeMetaData> attributesMetaData)
Compares the variants (including the master variants) of a
ProductDraft and a Product. |
@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildChangeNameUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString names of a ProductDraft and a Product. It returns an
ChangeName as a result in an Optional. If both the Product and the ProductDraft
have the same name, then no update action is needed and hence an empty Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new name.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetDescriptionUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString descriptions of a ProductDraft and a Product. It returns an
SetDescription as a result in an Optional. If both the Product and the
ProductDraft have the same description, then no update action is needed and hence an empty
Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new description.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildChangeSlugUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString slugs of a ProductDraft and a Product. It returns a
ChangeSlug update action as a result in an Optional. If both the Product and the
ProductDraft have the same slug, then no update action is needed and hence an empty Optional is
returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new slug.@Nonnull
public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildAddToCategoryUpdateActions(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
Set of Category References of a ProductDraft and a Product.
It returns a List of AddToCategory update actions as a result, if the old product
needs to be added to a category to have the same set of categories as the new product.
If both the Product and the ProductDraft have the same set of categories, then no update actions
are needed and hence an empty List is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new slug.@Nonnull
public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetCategoryOrderHintUpdateActions(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
CategoryOrderHints of a ProductDraft and a Product. It returns a
SetCategoryOrderHint update action as a result in an List. If both the Product and the
ProductDraft have the same categoryOrderHints, then no update actions are needed and hence an empty
List is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new categoryOrderHints.@Nonnull
public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildRemoveFromCategoryUpdateActions(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
Set of Category References of a ProductDraft and a Product.
It returns a List of RemoveFromCategory update actions as a result, if the old product
needs to be removed from a category to have the same set of categories as the new product.
If both the Product and the ProductDraft have the same set of categories, then no update actions
are needed and hence an empty List is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new slug.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetSearchKeywordsUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
SearchKeywords of a ProductDraft and a Product. It returns a
SetSearchKeywords update action as a result in an Optional. If both the Product and the
ProductDraft have the same search keywords, then no update action is needed and hence an empty
Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new search keywords.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetMetaDescriptionUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString meta descriptions of a ProductDraft and a Product. It
returns a SetMetaDescription update action as a result in an Optional. If both the
Product and the ProductDraft have the same meta description, then no update action is needed and
hence an empty Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new meta description.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetMetaKeywordsUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString meta keywordss of a ProductDraft and a Product. It returns
a SetMetaKeywords update action as a result in an Optional. If both the Product and the
ProductDraft have the same meta keywords, then no update action is needed and hence an empty
Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new meta keywords.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildSetMetaTitleUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
LocalizedString meta titles of a ProductDraft and a Product. It returns a
SetMetaTitle update action as a result in an Optional. If both the Product and the
ProductDraft have the same meta title, then no update action is needed and hence an empty
Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new meta title.@Nonnull
public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildVariantsUpdateActions(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct,
@Nonnull
ProductSyncOptions syncOptions,
@Nonnull
java.util.Map<java.lang.String,AttributeMetaData> attributesMetaData)
ProductDraft and a Product. It returns
a List of variant related update actions. For example:
AddVariantRemoveVariantChangeMasterVariantSetAttributeSetAttributeInAllVariantsSetSkuAddExternalImageRemoveImageAddPriceProduct and the ProductDraft have identical variants, then no update actions are
needed and hence an empty List is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new meta title.syncOptions - the sync options wrapper which contains options related to the sync process supplied by
the user. For example, custom callbacks to call in case of warnings or errors occurring
on the build update action process. And other options (See ProductSyncOptions
for more info).attributesMetaData - a map of attribute name -> AttributeMetaData; which defines attribute
information: its name and whether it has the constraint "SameForAll" or not.@Nonnull
public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildPublishUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
ProductDraft and a Product and accordingly returns
a Publish or Unpublish update action as a result in an Optional. If the new product's
'published' field is null, then the default false value is assumed.
If both the Product and the ProductDraft have the same 'published' flag value, then no update
action is needed and hence an empty Optional is returned.
NOTE: Comparison is done against the staged projection of the old product.
oldProduct - the product which should be updated.newProduct - the product draft where we get the new published field value.@Nonnull
public static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildChangeMasterVariantUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct,
@Nonnull
ProductSyncOptions syncOptions)
newProduct has #masterVariant#key different than oldProduct
staged #masterVariant#key.
If update action is created - it is created of
newProduct.getMasterVariant().getSku()
If old master variant is missing in the new variants list - add RemoveVariant action at the end.
oldProduct - old product with variantsnewProduct - new product draft with variants with resolved references prices referencessyncOptions - the sync options wrapper which contains options related to the sync processChangeMasterVariant if the keys are different,
optionally followed by RemoveVariant if the changed variant does not exist in the new variants list.@Nonnull
public static java.util.Optional<io.sphere.sdk.products.commands.updateactions.SetTaxCategory> buildSetTaxCategoryUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
TaxCategory references of an old Product and
new ProductDraft. If they are different - return SetTaxCategory update action.
If the old value is set, but the new one is empty - the command will unset the tax category.
oldProduct - the product which should be updated.newProduct - the product draft with new TaxCategory reference.SetTaxCategory update action.@Nonnull
public static java.util.Optional<io.sphere.sdk.products.commands.updateactions.TransitionState> buildTransitionStateUpdateAction(@Nonnull
io.sphere.sdk.products.Product oldProduct,
@Nonnull
io.sphere.sdk.products.ProductDraft newProduct)
State references of an old Product and
new ProductDraft. If they are different - return TransitionState update action.
If the old value is set, but the new one is empty - return empty object, because unset transition state is not possible.
Note: the transition state action is called with force == true, i.e. the platform won't verify transition
oldProduct - the product which should be updated.newProduct - the product draft with new State reference.TransitionState update action.