aem-core-cif-components: Custom attribute not being fetched from Magento
I am not able to fetch custom attributes which are created in Magento. If you see the logs below, my custom attribute is not present in any of the graph QL queries that are being fired. And, my custom product model is initiated after the all queries are fired. I am able to fetch the same custom attribute when I manually query for the attribute.
There are no queries fired at any point after this line is executed:
productRetriever.extendProductQueryWith(p -> p .addCustomSimpleField("custom_attribute")
What have I tried so far?
- As mentioned here, I have tried creating a new CustomPageMetadata and overlayed head.html in page component to use my custom product model
- Cleared classloader cache
But it has not worked so far.
Expected Behaviour
When the steps given here are followed, custom attributes must be fetched from Magento
Actual Behaviour
Custom attributes configured in Magento are not being fetched by custom product implementation.
Reproduce Scenario (including but not limited to)
Follow the steps given here
Steps to Reproduce
Follow the steps given here
Platform and Version
AEM Version: 6.5.9 Core Components: 2.17.2 Core CIF Components: 2.0.0 Magento GraphQL Version: 9.0.0-magento242ee GraphQL version: 1.7.1
Sample Code that illustrates the problem
Logs taken while reproducing problem
14.08.2021 10:05:12.894 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:12.895 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:12.900 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.internal.models.v1.page.PageMetadataImpl Looking for child resource type ‘core/cif/components/commerce/product/v1/product’ from /content/demoproject/us/en/products/product-page/jcr:content 14.08.2021 10:05:12.900 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.internal.models.v1.page.PageMetadataImpl Looking for child resource type ‘core/cif/components/commerce/product/v1/product’ from /content/demoproject/us/en/products/product-page/jcr:content/root 14.08.2021 10:05:12.900 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.internal.models.v1.page.PageMetadataImpl Looking for child resource type ‘core/cif/components/commerce/product/v1/product’ from /content/demoproject/us/en/products/product-page/jcr:content/root/container 14.08.2021 10:05:12.900 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.internal.models.v1.page.PageMetadataImpl Looking for child resource type ‘core/cif/components/commerce/product/v1/product’ from /content/demoproject/us/en/products/product-page/jcr:content/root/container/container 14.08.2021 10:05:12.900 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.internal.models.v1.page.PageMetadataImpl Found child resource type ‘core/cif/components/commerce/product/v1/product’ at /content/demoproject/us/en/products/product-page/jcr:content/root/container/container/product 14.08.2021 10:05:12.901 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:12.901 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:12.907 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:12.907 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:12.907 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{url_key:{eq:“prod-name”}}){items{__typename,sku,url_key}}} 14.08.2021 10:05:13.673 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{sku:{eq:“1234”}}){items{__typename,sku,name,description{html},image{label,url},thumbnail{label,url},url_key,stock_status,meta_description,meta_keyword,meta_title,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},media_gallery{__typename,disabled,url,label,position},categories{__typename,uid,name,image},… on ConfigurableProduct{price_range{maximum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},configurable_options{label,attribute_code,values{value_index,label}},variants{attributes{code,value_index},product{sku,name,description{html},image{label,url},thumbnail{label,url},url_key,stock_status,color,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}},media_gallery{__typename,disabled,url,label,position},categories{__typename,uid,name,image},staged}}},… on GroupedProduct{items{position,qty,product{__typename,sku,name,price_range{minimum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}}}}},… on BundleProduct{price_range{maximum_price{regular_price{value,currency},final_price{value,currency},discount{amount_off,percent_off}}}},staged}}} 14.08.2021 10:05:14.564 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:14.564 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:14.572 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {categoryList(filters:{category_uid:{eq:“3”}}){uid,name,url_path,position,children{uid,name,url_path,position,children{uid,name,url_path,position}}}} 14.08.2021 10:05:15.429 WARN [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl GraphQL request {categoryList(filters:{category_uid:{eq:“3”}}){uid,name,url_path,position,children{uid,name,url_path,position,children{uid,name,url_path,position}}}} returned some errors [{“message”:“Value of uid "3" is incorrect.”,“locations”:[{“line”:1,“column”:2}]}] 14.08.2021 10:05:15.447 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:15.447 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:15.450 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{sku:{eq:“1234”}}){items{__typename,sku,url_key,name,categories{__typename,uid,url_path,name,breadcrumbs{category_uid,category_url_path,category_name}}}}} 14.08.2021 10:05:16.174 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Try to get a graphql client from the resource at /content/demoproject/us/en/products/product-page 14.08.2021 10:05:16.174 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.core.components.client.MagentoGraphqlClient Crafting a configuration resource and attempting to get a GraphQL client from it… 14.08.2021 10:05:16.175 DEBUG [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl Executing GraphQL query: {products(filter:{sku:{eq:“1234”}}){items{__typename,url_key,url_path}}} 14.08.2021 10:05:16.950 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Inside init method:::::::1234 14.08.2021 10:05:16.950 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl extending query 14.08.2021 10:05:16.951 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Outside if 14.08.2021 10:05:16.953 INFO [[0:0:0:0:0:0:0:1] [1628915712880] GET /content/demoproject/us/en/products/product-page.html/prod-name.html HTTP/1.1] com.demo.core.models.impl.CustomProductModelImpl Inside custom attribute get method
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (7 by maintainers)
I WAS experiencing the same issue. What resolved my issue was adding Product.class to the adapter field in the Model annotation.