Expand my Community achievements bar.

SOLVED

Fetching custom header details from AEM CIF cloud config for multi region, langauge application

Avatar

Level 2

Hello team,

 

Query is related to: CIF graphql configuration

In my application, we have introduced region, language based (Multi region) product display.

For this, I have created separate CIF configurations under these folders.


/conf/abc/FR/en
/conf/abc/FR/fr

/conf/abc/GB/gb
/conf/abc/GB/en

Also, enabled custom http headers using: com.adobe.cq.cif.http.internal.HttpHeadersConfigProviderImpl

Now, in above 4 CIF configurations, I have eneabled custom httpHeaders : region, language: 

example: /conf/abc/FR/en

region: fr, language: en

/conf/abc/FR/fr  Here region: fr, language: fr

Now, in my content pages, I will mentione these in the page properties -> Advanced -> Cloud configuration
example: /content/abc/fr/en : mentioning: /conf/abc/FR/en
/content/abc/fr/fr : mentioning: /conf/abc/FR/fr

Now, I need to get the headers details: /conf/abc/FR/en/settings/cloudconfigs/commerce/jcr:content/httpHeadersTree
in my sling model. will get "cq:conf" path. Then, go to the httpHeadersTree section
Get all details. pass this while calling the graphQL API.

Is this approach right? Wanted to utilize out of the box feature in most of the cases.

Note: As of now, in my custom sling model class, to get the MagentoGraphqlClient object, using this config file:  com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl~default.cfg

 

Thanks in advance

 

cc @Hemalatha  @AMANATH_ULLAH  @MukeshYadav_  @pulkitvashisth 

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @TarunKumar 

 

Ignore my query. Got the solution. 

com.adobe.cq.commerce.core.components.internal.client.MagentoGraphqlClientImpl does the task for me. This is the out of the box feature provided by AEM CIF, where MagentoGraphqlClientImpl.java reads the CIF cloud configuration.

View solution in original post

2 Replies

Avatar

Community Advisor

HI @MaheshaGu ,

Content references its associated configuration via a cq:Conf property.
AEM performs a lookup based on the content and its contextual cq:Conf property to find the appropriate configuration. So , you should be able to derive the Conf value from model class.

The code would would look something like this, this is just sample logic:

Conf conf = resource.adaptTo(Conf.class);
ValueMap confProp= conf.getItem("<your-config-path-after-settings-till-pagenode>");
String region = confProp.get("region", "FR");

 

For debugging and testing purposes, there is a ConfMgr web console at https://<host>:<port>/system/console/conf, which can show configurations for a given path/item.

 

-Tarun

Avatar

Correct answer by
Level 2

Hi @TarunKumar 

 

Ignore my query. Got the solution. 

com.adobe.cq.commerce.core.components.internal.client.MagentoGraphqlClientImpl does the task for me. This is the out of the box feature provided by AEM CIF, where MagentoGraphqlClientImpl.java reads the CIF cloud configuration.