Expand my Community achievements bar.

SOLVED

How to generate pages if a url matches a certain pattern

Avatar

Level 5

I am investigating how we might use AEM to front our Ecommerce site. The key advantage I want to get out of this is that AEM allows the merchandisers to customise the look and feel of an ecommerce page without a full deploy of code etc if it is much more than a text change like we have now.

I'm sort of wondering what is the best way to handle things like different category pages for example. There are hundreds of these pages and the way I can see to do it is to create a base page eg /content/store/categories/baseCategoryPage and when somebody hits the url /content/store/categories/bread check to see if that page exists if not use the base category page. I also need each category page to have its own url for SEO reasons 

This seems a sensible approach to me as it does not require every page to be created and maintained but it gives the team the ability to customise a certain category page if they wish to.

However how in AEM can I go about doing this, how can I specify a url pattern eg /content/store/categories/* that maps to this generic category page unless there is a specific page which fully matches the url?

Any thoughts would be great!

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

using the 404 page is not recommended, as you suggest it is a misuse of the error handler.

In version 5.6 of AEM, I created a servlet that would take in a product ID which would then return the appropriate product page to the user. This would be a better approach than using the 404 functionality.

With AEM 6 and beyond, ecommerce functionality has moved on greatly, please go through [1] which should give you an understanding of how it is implemented in AEM.

Regards,

Opkar

[1]https://docs.adobe.com/docs/en/aem/6-1/administer/ecommerce/concepts.html

View solution in original post

5 Replies

Avatar

Employee

You can code this logic in to the 404.jsp. This is the jsp that gets called if any url returns a 404.

This jsp can be overlayed at /apps/sling/servlet/errorhandler/404.jsp

Avatar

Level 5

kalyanar wrote...

You can code this logic in to the 404.jsp. This is the jsp that gets called if any url returns a 404.

This jsp can be overlayed at /apps/sling/servlet/errorhandler/404.jsp

 

Is this best practice? Feels a little like I'm misusing the 404 handler a bit! I can however see that this would work so maybe this is the best approach!

Avatar

Correct answer by
Employee

Hi,

using the 404 page is not recommended, as you suggest it is a misuse of the error handler.

In version 5.6 of AEM, I created a servlet that would take in a product ID which would then return the appropriate product page to the user. This would be a better approach than using the 404 functionality.

With AEM 6 and beyond, ecommerce functionality has moved on greatly, please go through [1] which should give you an understanding of how it is implemented in AEM.

Regards,

Opkar

[1]https://docs.adobe.com/docs/en/aem/6-1/administer/ecommerce/concepts.html

Avatar

Employee

I misunderstood ur usecase i thnk

I more saw this as specific error page for 404 in specific content tree.

something like http://adobe-consulting-services.github.io/acs-aem-commons/features/errorpagehandler.html

If you want to run this in ur author site, you can use the  catalog based approach in AEM commerce framework as Opkar mentioned. You dont need redirection at all as am hoping in an author , the users would click through links in sites /siteadmin ui to access any page.

Avatar

Level 5

Thanks very much that sounds interesting!  We are on 5.6 at the moment but would most likely look at upgrading to 6.1 for this project.