【问题标题】:AEM CIF: Unable to fetch custom product attributes from MagentoAEM CIF:无法从 Magento 获取自定义产品属性
【发布时间】:2021-10-17 09:47:02
【问题描述】:

我无法获取使用 AEM Commerce 集成框架 (CIF) 在 Magento 中创建的自定义属性。如果您看到下面的日志,我的自定义属性不会出现在任何正在触发的图形 QL 查询中。而且,我的自定义产品模型是在所有查询都被触发后启动的。当我手动查询属性(通过邮递员)时,我能够获取相同的自定义属性。

在执行此行后,任何时候都不会触发任何查询:

productRetriever.extendProductQueryWith(p -> p.addCustomSimpleField("custom_attribute")

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}}}

##### Main Product Query Happens Here ####

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}}}

##### My Custom Product Model is initialized Here ####

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

### After this there are no graphql queries fired ###

【问题讨论】:

  • 产品是什么类型的?
  • 你是说产品组件的sling:resourceType?它是 CIF 产品的核心组件
  • 我的意思是 Magento 产品类型。如果它是一个简单的产品,捆绑产品等。

标签: aem aem-core-wcm-components


【解决方案1】:

您可能会遇到我刚刚在 core-cif-components 开发人员的帮助下设法解决的相同问题: https://github.com/adobe/aem-core-cif-components/issues/504

这个问题是开箱即用模型首先在 PageMetadataImpl.java 中初始化。然后将其缓存起来,这样它就不会被自定义查询再次触发。

事实证明,我只需要在我的自定义类的注释中添加原始的 Product.class 作为可调整项。这样它就被用作 PageMetadataImpl.java 中的模型实现。这不是我遵循的教程中的做法,这就是为什么它有点令人困惑。

【讨论】:

    猜你喜欢
    • 2016-07-16
    • 1970-01-01
    • 2013-08-02
    • 1970-01-01
    • 2013-04-10
    • 1970-01-01
    • 2016-11-24
    • 2014-02-10
    • 1970-01-01
    相关资源
    最近更新 更多