From bb27bc6ed21010f72326cc0e3c043841fed610a5 Mon Sep 17 00:00:00 2001 From: del60718 Date: Wed, 26 Aug 2026 16:10:40 +0530 Subject: [PATCH 1/4] staged feature changes --- .../models/v2/product/ProductImpl.java | 19 ++++++- .../v2/productlist/ProductListImpl.java | 19 ++++++- .../v1/productlist/ProductListImplTest.java | 4 +- .../models/v2/product/ProductImplTest.java | 56 +++++++++++++++++++ .../v2/productlist/ProductListImplTest.java | 56 +++++++++++++++++++ .../commerce/product/v2/product/README.md | 7 +++ .../productlist/v2/productlist/README.md | 13 +++++ 7 files changed, 170 insertions(+), 4 deletions(-) diff --git a/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImpl.java b/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImpl.java index b63e122af7..3123571267 100644 --- a/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImpl.java @@ -18,9 +18,11 @@ import javax.annotation.PostConstruct; import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; import com.adobe.cq.commerce.core.components.models.product.Product; +import com.adobe.cq.commerce.core.components.services.ComponentsConfiguration; import com.adobe.cq.commerce.magento.graphql.ConfigurableProduct; import com.adobe.cq.commerce.magento.graphql.GroupedProduct; import com.adobe.cq.commerce.magento.graphql.ProductInterface; @@ -33,15 +35,30 @@ public class ProductImpl extends com.adobe.cq.commerce.core.components.internal. public static final String RESOURCE_TYPE = "core/cif/components/commerce/product/v2/product"; + /** + * Name of the boolean configuration property controlling whether the Adobe Commerce Content Staging {@code staged} + * field is requested. Defaults to {@code true} to keep existing Adobe Commerce deployments unchanged. Magento Open + * Source backends, which do not support the {@code staged} field, must set this to {@code false}. + */ + protected static final String PN_ENABLE_STAGING = "enableContentStaging"; + @PostConstruct protected void initModel() { super.initModel(); - if (productRetriever != null) { + if (productRetriever != null && isStagingEnabled()) { productRetriever.extendProductQueryWith(p -> p.staged()); productRetriever.extendVariantQueryWith(v -> v.staged()); } } + private boolean isStagingEnabled() { + Resource contentResource = currentPage.adaptTo(Resource.class); + ComponentsConfiguration configProperties = contentResource != null + ? contentResource.adaptTo(ComponentsConfiguration.class) + : null; + return configProperties != null ? configProperties.get(PN_ENABLE_STAGING, Boolean.TRUE) : Boolean.TRUE; + } + @Override public Boolean isStaged() { // A product is considered "staged" if the product itself or one of its variant or item is "staged" diff --git a/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImpl.java b/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImpl.java index cbdf9f3734..5f3f67bb51 100644 --- a/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImpl.java @@ -18,9 +18,11 @@ import javax.annotation.PostConstruct; import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; import com.adobe.cq.commerce.core.components.models.productlist.ProductList; +import com.adobe.cq.commerce.core.components.services.ComponentsConfiguration; @Model( adaptables = SlingHttpServletRequest.class, @@ -31,15 +33,30 @@ public class ProductListImpl extends com.adobe.cq.commerce.core.components.inter public static final String RESOURCE_TYPE = "core/cif/components/commerce/productlist/v2/productlist"; + /** + * Name of the boolean configuration property controlling whether the Adobe Commerce Content Staging {@code staged} + * field is requested. Defaults to {@code true} to keep existing Adobe Commerce deployments unchanged. Magento Open + * Source backends, which do not support the {@code staged} field, must set this to {@code false}. + */ + protected static final String PN_ENABLE_STAGING = "enableContentStaging"; + @PostConstruct protected void initModel() { super.initModel(); - if (categoryRetriever != null) { + if (categoryRetriever != null && isStagingEnabled()) { categoryRetriever.extendCategoryQueryWith(c -> c.staged()); categoryRetriever.extendProductQueryWith(p -> p.staged()); } } + private boolean isStagingEnabled() { + Resource contentResource = currentPage.adaptTo(Resource.class); + ComponentsConfiguration configProperties = contentResource != null + ? contentResource.adaptTo(ComponentsConfiguration.class) + : null; + return configProperties != null ? configProperties.get(PN_ENABLE_STAGING, Boolean.TRUE) : Boolean.TRUE; + } + @Override public Boolean isStaged() { return getCategory() != null ? Boolean.TRUE.equals(getCategory().getStaged()) : false; diff --git a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v1/productlist/ProductListImplTest.java b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v1/productlist/ProductListImplTest.java index 6199a08bdf..6ecc9f7502 100644 --- a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v1/productlist/ProductListImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v1/productlist/ProductListImplTest.java @@ -149,11 +149,11 @@ public class ProductListImplTest { private static final String PRODUCT_LIST_WITH_MULTIPLE_XF = "/content/pageA/jcr:content/root/responsivegrid/productlist_with_multiple_xf"; private Resource productListResource; - private Resource pageResource; + protected Resource pageResource; protected ProductListImpl productListModel; private CategoryTree category; private Products products; - private GraphqlClient graphqlClient; + protected GraphqlClient graphqlClient; @Mock CloseableHttpClient httpClient; diff --git a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java index a33a036b1f..23c1a7a87e 100644 --- a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java @@ -16,6 +16,23 @@ package com.adobe.cq.commerce.core.components.internal.models.v2.product; import java.io.IOException; +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.wrappers.ValueMapDecorator; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.ArgumentCaptor; + +import com.adobe.cq.commerce.core.components.services.ComponentsConfiguration; +import com.adobe.cq.commerce.graphql.client.GraphqlRequest; +import com.google.common.collect.ImmutableMap; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class ProductImplTest extends com.adobe.cq.commerce.core.components.internal.models.v1.product.ProductImplTest { @@ -39,4 +56,43 @@ public void testGroupedProduct() throws IOException { public void testBundleProduct() throws IOException { testBundleProductImpl(true); } + + /** + * By default (no {@code enableContentStaging} configuration) the {@code staged} field is added to the product and + * variant queries so that the author-only "Staged" badge keeps working on Adobe Commerce deployments. + */ + @Test + public void testStagedFieldQueriedByDefault() { + Assert.assertTrue("staged must be queried by default", executedQueriesContainStaged()); + } + + /** + * When {@code enableContentStaging} is set to {@code false} (e.g. for Magento Open Source backends that do not + * support the Content Staging {@code staged} field), the {@code staged} field must not be added to any query so + * that the query stays schema-valid. + */ + @Test + public void testStagedFieldOmittedWhenStagingDisabled() { + ValueMap configMap = new ValueMapDecorator(ImmutableMap.of( + "cq:graphqlClient", "default", + "magentoStore", "my-store", + "enableUIDSupport", "true", + "enableContentStaging", false)); + ComponentsConfiguration stagingDisabled = new ComponentsConfiguration(configMap); + when(pageResource.adaptTo(ComponentsConfiguration.class)).thenReturn(stagingDisabled); + + Assert.assertFalse("staged must not be queried when content staging is disabled", executedQueriesContainStaged()); + } + + private boolean executedQueriesContainStaged() { + adaptToProduct(); + // Trigger the product data fetch which executes the GraphQL query. + productModel.getName(); + + ArgumentCaptor captor = ArgumentCaptor.forClass(GraphqlRequest.class); + verify(graphqlClient, atLeastOnce()).execute(captor.capture(), any(), any(), any()); + + List requests = captor.getAllValues(); + return requests.stream().anyMatch(request -> request.getQuery().contains("staged")); + } } diff --git a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java index 90910400c0..030dd051f3 100644 --- a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java @@ -15,6 +15,24 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ package com.adobe.cq.commerce.core.components.internal.models.v2.productlist; +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.wrappers.ValueMapDecorator; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.ArgumentCaptor; + +import com.adobe.cq.commerce.core.components.services.ComponentsConfiguration; +import com.adobe.cq.commerce.graphql.client.GraphqlRequest; +import com.google.common.collect.ImmutableMap; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + public class ProductListImplTest extends com.adobe.cq.commerce.core.components.internal.models.v1.productlist.ProductListImplTest { @Override @@ -27,4 +45,42 @@ protected void adaptToProductList() { public void testStagedData() { testStagedDataImpl(true); } + + /** + * By default (no {@code enableContentStaging} configuration) the {@code staged} field is added to the queries so + * that the author-only "Staged" badge keeps working on Adobe Commerce deployments. + */ + @Test + public void testStagedFieldQueriedByDefault() { + Assert.assertTrue("staged must be queried by default", executedQueriesContainStaged()); + } + + /** + * When {@code enableContentStaging} is set to {@code false} (e.g. for Magento Open Source backends that do not + * support the Content Staging {@code staged} field), the {@code staged} field must not be added to any query so + * that the query stays schema-valid. + */ + @Test + public void testStagedFieldOmittedWhenStagingDisabled() { + ValueMap configMap = new ValueMapDecorator(ImmutableMap.of( + "cq:graphqlClient", "default", + "magentoStore", "my-store", + "enableUIDSupport", "true", + "enableContentStaging", false)); + ComponentsConfiguration stagingDisabled = new ComponentsConfiguration(configMap); + when(pageResource.adaptTo(ComponentsConfiguration.class)).thenReturn(stagingDisabled); + + Assert.assertFalse("staged must not be queried when content staging is disabled", executedQueriesContainStaged()); + } + + private boolean executedQueriesContainStaged() { + adaptToProductList(); + productListModel.getProducts(); + + ArgumentCaptor captor = ArgumentCaptor.forClass(GraphqlRequest.class); + verify(graphqlClient, atLeastOnce()).execute(captor.capture(), any(), any(), any()); + + List requests = captor.getAllValues(); + return requests.stream().anyMatch(request -> request.getQuery().contains("staged")); + } } diff --git a/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/product/v2/product/README.md b/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/product/v2/product/README.md index 9f208044dc..0338fcf6a9 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/product/v2/product/README.md +++ b/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/product/v2/product/README.md @@ -17,6 +17,13 @@ Product (v2) ==== The version 2 of the product component extends the v1 product component by extending the v1 GraphQL query with the `staged` field introduced in Magento 2.4.2 Enterprise Edition (EE). This hence requires that the Magento backend is at least version 2.4.2 EE because the query with the `staged` field will be rejected by Magento versions not having this field in the GraphQL schema. +The `staged` field is only available on Adobe Commerce (formerly Magento EE) and does not exist in the Magento Open Source GraphQL schema. Requesting it against Magento Open Source results in a GraphQL validation error that breaks the product detail page. To support Magento Open Source, set the `enableContentStaging` property to `false` on the CIF commerce configuration; the `staged` field is then omitted from the product and variant queries and the "Staged" badge is not shown. + +### CIF Commerce Configuration Properties +The following property is read from the CIF commerce configuration (`ComponentsConfiguration`): + +1. `enableContentStaging` - when `true` (default), the `staged` field is added to the product and variant queries to drive the author-only "Staged" badge. Set to `false` for Magento Open Source backends, which do not support the `staged` field. + ## BEM Description In addition to the elements documented for the version 1 of the product component, version 2 introduces this extra element to display a "staged" flag. Note that this is only relevant for AEM author instances. diff --git a/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/productlist/v2/productlist/README.md b/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/productlist/v2/productlist/README.md index 00eb12f232..6f41bc354a 100644 --- a/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/productlist/v2/productlist/README.md +++ b/ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/productlist/v2/productlist/README.md @@ -22,6 +22,19 @@ This hence requires that the Magento backend is at least version 2.4.2 EE because the query with the `staged` field will be rejected by Magento versions not having this field in the GraphQL schema. +The `staged` field is only available on Adobe Commerce (formerly Magento EE) and does not exist +in the Magento Open Source GraphQL schema. Requesting it against Magento Open Source results in a +GraphQL validation error that breaks the product list page. To support Magento Open Source, set the +`enableContentStaging` property to `false` on the CIF commerce configuration (see below); the +`staged` field is then omitted from the query and the "Staged" badge is not shown. + +### CIF Commerce Configuration Properties +The following property is read from the CIF commerce configuration (`ComponentsConfiguration`): + +1. `enableContentStaging` - when `true` (default), the `staged` field is added to the category and + product queries to drive the author-only "Staged" badge. Set to `false` for Magento Open Source + backends, which do not support the `staged` field. + ### Component Policy Configuration Properties The following configuration properties are used: From be3b1c2e0969f5cf417444c310391f37dc3fd2f9 Mon Sep 17 00:00:00 2001 From: del60718 Date: Thu, 27 Aug 2026 18:40:21 +0530 Subject: [PATCH 2/4] staged feature changes --- .../components/internal/models/v2/product/ProductImplTest.java | 1 - .../internal/models/v2/productlist/ProductListImplTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java index 23c1a7a87e..24f19c20df 100644 --- a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/product/ProductImplTest.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.util.List; -import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; import org.apache.sling.api.wrappers.ValueMapDecorator; import org.junit.Assert; diff --git a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java index 030dd051f3..d6fe1c0dd3 100644 --- a/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/commerce/core/components/internal/models/v2/productlist/ProductListImplTest.java @@ -17,7 +17,6 @@ import java.util.List; -import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ValueMap; import org.apache.sling.api.wrappers.ValueMapDecorator; import org.junit.Assert; From e2f2881c3351eec3eefec3cb38f604e7bae62b64 Mon Sep 17 00:00:00 2001 From: satish Date: Thu, 27 Aug 2026 19:29:06 +0530 Subject: [PATCH 3/4] Fixs the relative.path issue from parent pom (#1096) Co-authored-by: Alwin Joseph --- it/site/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/it/site/pom.xml b/it/site/pom.xml index 4711e1e8a0..411ab1594c 100644 --- a/it/site/pom.xml +++ b/it/site/pom.xml @@ -20,7 +20,7 @@ com.adobe.commerce.cif core-cif-components-parent - 2.18.7-SNAPSHOT + 2.18.8 ../../parent/pom.xml From 9911766923019a778ca24c1e5dd2ad5efcfc696f Mon Sep 17 00:00:00 2001 From: satish Date: Fri, 28 Aug 2026 17:52:32 +0530 Subject: [PATCH 4/4] Update pom.xml --- it/site/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/it/site/pom.xml b/it/site/pom.xml index 411ab1594c..4711e1e8a0 100644 --- a/it/site/pom.xml +++ b/it/site/pom.xml @@ -20,7 +20,7 @@ com.adobe.commerce.cif core-cif-components-parent - 2.18.8 + 2.18.7-SNAPSHOT ../../parent/pom.xml