public final class SetMetaTitle extends UpdateActionImpl<Product>
See also ProductUpdateCommand.
withUpdateableProduct(client(), product -> {
final LocalizedString metaTitle = LocalizedString
.of(ENGLISH, "commercetools™ - Next generation eCommerce");
final SetMetaTitle action = SetMetaTitle.of(metaTitle);
final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, action));
assertThat(updatedProduct.getMasterData().getStaged().getMetaTitle()).isEqualTo(metaTitle);
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 |
getMetaTitle() |
static SetMetaTitle |
of(LocalizedString metaTitle) |
getAction
public static SetMetaTitle of(@Nullable LocalizedString metaTitle)
@Nullable public LocalizedString getMetaTitle()