@Override public Optional<LocalizedStrings> getMetaKeywords() { return productData.getMetaKeywords(); }
@Override public Optional<LocalizedStrings> getMetaKeywords() { return productData.getMetaKeywords(); }
@Override @Nullable public LocalizedString getMetaKeywords() { return productData.getMetaKeywords(); }
@Override @Nullable public LocalizedString getMetaKeywords() { return productData.getMetaKeywords(); }
@Override @Nullable public LocalizedString getMetaKeywords() { return productData.getMetaKeywords(); }
@Test public void setMetaAttributes() throws Exception { withUpdateableProduct(client(), product -> { final MetaAttributes metaAttributes = MetaAttributes.metaAttributesOf(ENGLISH, "commercetools SPHERE.IO™ - Next generation eCommerce", "SPHERE.IO™ 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; }); }
@Test public void setMetaKeywords() throws Exception { 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; }); }
@Test public void productProjectionCanBeUsedToUpdateAProduct() throws Exception { withUpdateableProduct(client(), product -> { final MetaAttributes metaAttributes = MetaAttributes.metaAttributesOf(ENGLISH, "commercetools SPHERE.IO™ - Next generation eCommerce", "SPHERE.IO™ 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 ProductProjection productProjection = client().executeBlocking(ProductProjectionByIdGet.of(product, STAGED)); final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(productProjection, 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; }); }