public final class MetaAttributesUpdateActions extends Base
Create update actions to set the SEO attributes title, description and keywords altogether:
withUpdateableProduct(client(), product -> { final MetaAttributes metaAttributes = MetaAttributes.metaAttributesOf(ENGLISH, "commercetools™ - Next generation eCommerce", "commercetools™ is the first and leading Platform-as-a-Service solution for eCommerce.", "Platform-as-a-Service, e-commerce, http, api, tool"); final List<UpdateAction<Product>> updateActions = MetaAttributesUpdateActions.of(metaAttributes); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, updateActions)); final ProductData productData = updatedProduct.getMasterData().getStaged(); assertThat(productData.getMetaTitle()).isEqualTo(metaAttributes.getMetaTitle()); assertThat(productData.getMetaDescription()).isEqualTo(metaAttributes.getMetaDescription()); assertThat(productData.getMetaKeywords()).isEqualTo(metaAttributes.getMetaKeywords()); return updatedProduct; });
See the test code.
See also ProductUpdateCommand.
Modifier and Type | Method and Description |
---|---|
static List<UpdateAction<Product>> |
of(MetaAttributes metaAttributes) |
public static List<UpdateAction<Product>> of(MetaAttributes metaAttributes)