Expand my Community achievements bar.

MagentoGraphqlClient

Avatar

Level 2

how to create MagentoGraphqlClient conection ?

in order to execute graphql queries to fetch products from magento

13 Replies

Avatar

Community Advisor

This article from Adobe gives you pretty much everything to start to CIF integration with AEM

https://experienceleague.adobe.com/docs/experience-manager-65/commerce/storefront/getting-started.ht...

 

Make sure you have all the details of the Magento client like URL, username, password and root category to pick the catalog data

This will be a cloud configuration that needs to be added which is explained in detail in the article.

Avatar

Community Advisor

Add store/ url required details in OSGI config - com.adobe.cq.commerce.graphql.client.impl.GraphqlClientImpl~<identifier>.cfg.json

then create cloudconfig of the store view

  1. In AEM go to Tools -> Cloud Services -> CIF Configuration

  2. Select the commerce configuration you want to change

  3. Open the configuration properties via the action bar

and configure to site hierarchy

 

Refer detailed adobe doc https://experienceleague.adobe.com/docs/experience-manager-65/commerce/storefront/getting-started.ht...

backend side to get MagentoGraphqlClient object:

MagentoGraphqlClient magentoGraphQLclientObject = resource.adaptTo(MagentoGraphqlClientImpl.class): request.adaptTo(MagentoGraphqlClientImpl.class);  

Avatar

Level 2

Hi Heena Madan,

Getting  build error while using 

MagentoGraphqlClient magentoGraphQLclientObject = resource.adaptTo(MagentoGraphqlClientImpl.class);

 

[ERROR] The analyser found the following errors for author and publish :
[ERROR] [api-regions-exportsimports] com.aem.magento:aem-magento.core:1.0.0-SNAPSHOT: Bundle aem-magento.core:1.0.0-SNAPSHOT is importing package(s) com.adobe.cq.commerce.core.components.internal.client in start level 20 but no bundle is exporting these for that start level. (com.aem.magento:aem-magento.all:1.0.0-SNAPSHOT)

 

I have used,

<dependency>
<artifactId>core-cif-components-core</artifactId>
<version>2.12.0</version>
<groupId>com.adobe.commerce.cif</groupId>
<scope>provided</scope>
</dependency>

 

Avatar

Community Advisor

If bundle is not found at start level 20- you need to export these jars. embed required cif and magento jar in "all" module 

<!-- Adobe CIF Dependencies -->
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-apps</artifactId>
                            <type>zip</type>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-config</artifactId>
                            <type>zip</type>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>core-cif-components-core</artifactId>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>magento-graphql</artifactId>
                            <target>/apps/<project-packages/application/install</target>
                        </embedded>
                        <embedded>
                            <groupId>com.adobe.commerce.cif</groupId>
                            <artifactId>graphql-client</artifactId>
                            <target>/apps/project-packages/application/install</target>
                        </embedded>

 

Avatar

Level 2

these dependencies are already there in all module pom.

Still not working

Avatar

Level 1

I am also facing this issue. Any solution you found for this ?

Avatar

Level 2

Any luck with this issue? I am having the same problem with my custom product component.

MagentoGraphqlClient is not getting injected in my CustomProductImpl even though I have all required OSGI configurations done. Due to this, I am getting magentoGraphqlClient object as null. I kept debug pointer in OOTB ProductImpl as well, and over there I can see the object is getting initialised. 


Strange thing, the injection in my local works fine some times and some times it doesn’t. In AEM cloud Dev ,magentoGraphqlClient is always null.

Avatar

Community Advisor

Have you configured commerce endpoint in AEM cloud instance? If not, it will give you null magentoGraphql client

Avatar

Level 2

yep, that's configured in cloud manager. All OSGI configs are also fine. 

all dependencies and embeds are done in pom files. 

Avatar

Community Advisor

Can you check bundles are active with perfect OSGI config? You can verify in developer console

Avatar

Level 2

Yep, all bundles are active.

 

One observation was OSGI component for GraphqlClientImpl was appearing as Satisfied instead of active. Checked it via  developer console.

Any idea why would the status go into  satisfied state?

Avatar

Community Advisor

seems version mismatch..Can you check version of bundles that is available in aem cloud and what you are passing?