Class ProductReferenceResolutionUtils
- java.lang.Object
-
- com.commercetools.sync.products.utils.ProductReferenceResolutionUtils
-
public final class ProductReferenceResolutionUtils extends java.lang.Object
Util class which provides utilities that can be used when syncing resources from a source commercetools project to a target one.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<com.commercetools.api.models.product.Attribute>
createAttributes(java.util.List<com.commercetools.api.models.product.Attribute> attributes)
static com.commercetools.api.models.product.ProductVariantDraft
createProductVariantDraft(com.commercetools.api.models.product.ProductVariant productVariant)
static com.commercetools.api.models.product.ProductDraftBuilder
getDraftBuilderFromStagedProduct(com.commercetools.api.models.product.ProductProjection product)
Given aProduct
this method creates aProductDraftBuilder
based on the staged projection values of the supplied product.static java.util.List<com.commercetools.api.models.product.ProductDraft>
mapToProductDrafts(java.util.List<com.commercetools.api.models.product.ProductProjection> products, ReferenceIdToKeyCache referenceIdToKeyCache)
Returns anList
<ProductDraft
> consisting of the results of applying the mapping from the staged version of aProductProjection
toProductDraft
with considering reference resolution.
-
-
-
Method Detail
-
mapToProductDrafts
@Nonnull public static java.util.List<com.commercetools.api.models.product.ProductDraft> mapToProductDrafts(@Nonnull java.util.List<com.commercetools.api.models.product.ProductProjection> products, @Nonnull ReferenceIdToKeyCache referenceIdToKeyCache)
Returns anList
<ProductDraft
> consisting of the results of applying the mapping from the staged version of aProductProjection
toProductDraft
with considering reference resolution.Mapping of Reference fields for the reference resolution Reference field from to productType ProductTypeReference
ProductTypeResourceIdentifier
categories List
<CategoryReference
>List
<CategoryResourceIdentifier
>variants.prices.channel ChannelReference
ChannelResourceIdentifier
variants.prices.customerGroup * CustomerGroupReference
CustomerGroupResourceIdentifier
variants.prices.custom.type TypeReference
TypeResourceIdentifier
variants.assets.custom.type TypeReference
TypeResourceIdentifier
variants.attributes on List
<Attribute
*ProductTypeReference
(example for ProductType)ProductTypeReference
(with key replaced with id field)taxCategory TaxCategoryReference
TaxCategoryResourceIdentifier
state * StateReference
StateResourceIdentifier
Note: The aforementioned references should contain Id in the map(cache) with a key value. Any reference that is not available in the map will have its id in place and not replaced by the key. This reference will be considered as existing resources on the target commercetools project and the library will issues an update/create API request without reference resolution.
- Parameters:
products
- the productprojection (staged) without expansion of references.referenceIdToKeyCache
- the instance that manages cache.- Returns:
- a
List
ofProductDraft
built from the suppliedList
ofProduct
.
-
getDraftBuilderFromStagedProduct
@Nonnull public static com.commercetools.api.models.product.ProductDraftBuilder getDraftBuilderFromStagedProduct(@Nonnull com.commercetools.api.models.product.ProductProjection product)
Given aProduct
this method creates aProductDraftBuilder
based on the staged projection values of the supplied product.- Parameters:
product
- the product to create aProductDraftBuilder
based on it's staged data.- Returns:
- a
ProductDraftBuilder
based on the staged projection values of the supplied product.
-
createProductVariantDraft
public static com.commercetools.api.models.product.ProductVariantDraft createProductVariantDraft(@Nonnull com.commercetools.api.models.product.ProductVariant productVariant)
-
createAttributes
public static java.util.List<com.commercetools.api.models.product.Attribute> createAttributes(java.util.List<com.commercetools.api.models.product.Attribute> attributes)
-
-