public final class SetMetaDescription extends UpdateActionImpl<Product>
See also ProductUpdateCommand.
withUpdateableProduct(client(), product -> {
final LocalizedString metaDescription = LocalizedString
.of(ENGLISH, "commercetools™ is the first Platform-as-a-Service solution for eCommerce.");
final SetMetaDescription action = SetMetaDescription.of(metaDescription);
final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, action));
assertThat(updatedProduct.getMasterData().getStaged().getMetaDescription()).isEqualTo(metaDescription);
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 |
getMetaDescription() |
static SetMetaDescription |
of(LocalizedString metaDescription) |
getAction
public static SetMetaDescription of(@Nullable LocalizedString metaDescription)
@Nullable public LocalizedString getMetaDescription()