public final class SetMetaKeywords extends UpdateActionImpl<Product>
See also ProductUpdateCommand.
withUpdateableProduct(client(), product -> {
final LocalizedString metaKeywords = LocalizedString
.of(ENGLISH, "Platform-as-a-Service, e-commerce, http, api, tool");
final SetMetaKeywords action = SetMetaKeywords.of(metaKeywords);
final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, action));
assertThat(updatedProduct.getMasterData().getStaged().getMetaKeywords()).isEqualTo(metaKeywords);
return updatedProduct;
});
See the test code.
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.
Modifier and Type | Method and Description |
---|---|
LocalizedString |
getMetaKeywords() |
static SetMetaKeywords |
of(LocalizedString metaKeywords) |
getAction
public static SetMetaKeywords of(@Nullable LocalizedString metaKeywords)
@Nullable public LocalizedString getMetaKeywords()