Expand my Community achievements bar.

save data in aem

Avatar

Level 1

I am creating a product page in which i want to display the data which is stored in aem . Where can I store that data and fetch it in the page 

4 Replies

Avatar

Level 3

Hello @rishikreddy 

 

To create a product page in Adobe Experience Manager (AEM) and display data stored in AEM, you can leverage the power of the Java Content Repository (JCR) and CQ:Dialogs. Here's a brief overview of how you can store and fetch data:

 

1. Use JCR for Data Storage :

JCR is the backbone of AEM's content storage. It provides a structured and organized way to store content, including product data. You can create a dedicated node or a hierarchy of nodes within the JCR repository to store your product-related information. For example:


/content/mywebsite/products/product1
/content/mywebsite/products/product2

Within these nodes, you can store properties like product name, description, price, images, and any other relevant data.

 

2. Leverage CQ:Dialogs for Data Entry:

CQ:Dialogs are a powerful tool in AEM for creating user-friendly forms to input and manage content. You can design a custom dialog for adding or editing product information. This dialog can include fields for product name, description, price, and any other attributes you need.

 

Once you create this dialog, you can associate it with your component to allow content authors to enter product data easily.

 

3. Retrieve Data for Display:

In your product page component, you can use AEM's Sling Models or servlets to fetch the product data stored in the JCR repository. You can then render this data on the product page template as needed. Here's a simplified example of fetching data in a Sling Model:


@Model(adaptables = SlingHttpServletRequest.class)
public class ProductModel {
@inject
private Resource resource;

public String getProductName() {
return resource.getValueMap().get("productName", String.class);
}

public String getProductDescription() {
return resource.getValueMap().get("productDescription", String.class);
}

// Add more getters for other product attributes
}

In your product page template (HTML or Sightly), you can use these getters to display the product information.

By using JCR for storage and CQ:Dialogs for data entry, you can effectively manage and display product data in your AEM-powered product page. This approach provides a structured and maintainable way to handle content in AEM.

Avatar

Community Advisor

Hello @rishikreddy 

 

The content on a page is authored and displayed via components. To develop a component, you would need to learn about templates, sightly, sling models etc.

I would request you to go through https://experienceleague.adobe.com/docs/experience-manager-learn/sites/components/component-developm...

 

There are few standard components provides by Adobe that can be readily used as well.

https://experienceleague.adobe.com/docs/experience-manager-core-components/using/introduction.html?l...


Aanchal Sikka

Avatar

Administrator

@rishikreddy Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 1

is there any other way to do this ??

like do we have any internal database in aem where i can directly store it ?

 

actually I have 12 products data that i have created in json file

so i am trying the jcr now