Isn’t it iconic? by Mykl Roventine
Convenience
eCommerce sites want to make their users’ experience as convenient and intuitive as possible. One convenience found on most major eCommerce sites is remembering what the user put in his shopping cart, even if that person didn’t log in. Therefore when the user returns to the site he will see what he left in his shopping cart.
Persistent Cart
ATG makes it relatively simple to do this by:
- creating a profile in the repository (database) for all users that visit the website
- automatically logging in users by cookie
Therefore if a user returns, she/he will be automatically logged in and if there were any items in his cart they will be added to the current cart.
Implementation
- Turn on persisting anonymous profiles in the ProfileRequestServlet.
[ruby]# /atg/dynamo/servlet/dafpipeline/ProfileRequestServlet
persistAfterLogout=true
persistentAnonymousProfiles=true[/ruby] - Turn on auto-login by cookie and turn off auto-login by basic authentication.
[ruby]# /atg/userprofiling/CookieManager
sendProfileCookies=true# /atg/userprofiling/ProfileRequestServlet
verifyBasicAuthentication=false[/ruby] - Make all profile properties not required except for login and password in userProfile.xml. Also make autoLogin true.
[xml]<table name="dps_user">
<property name="login" required="true" />
<property name="password" required="true" />
<property name="firstName" required="false" />
<property name="lastName" required="false" />
<property name="email" required="false" />
<property name="autoLogin" default="true" />
</table>[/xml]
Notes
When a profile is created for an anonymous user the login and password are set to the user’s ID (i.e. the profile’s repository ID).
If you are adding this functionality to an existing up and running site you may have to modify your user tables so that there no “not null†columns except for the id, login and password columns, you can leave those as how they were. Also you will need to set auto_login to true for all your existing users.
update dps_user set auto_login = 1;
To determine when the anonymous user was created look at the registrationDate profile property. To determine when was the last time the anonymous user logged in look at the lastActivity profile property. Both of these are updated by ATG’s TrackActivity scenario which is in the DSS folder.
Finally do not turn on persistent anonymous profiles in the BCC. It will stop working if you do that.
For further reading please see Tracking Guest Users and Tracking Registered Users in the ATG 9.1 Personalization Programming Guide.
Do you need to also set the following configuration properties in order for the cart to be persisted:
# Settings for persisting shoppingCart for logged in users
persistOrders=true
# Setting for persisting shopping cart of anonymous users
persistOrdersForAnonymousUsers=true
I haven’t seen those properties ever before. Which component is that?
These are located in the ShoppingCart.properties
I am using Ver 10.x
What would a SQL look like if I am trying to remove order from db. I ask because I have millions of records created that causes out of memory error on app server.
This is not easy, especially if you have any extensions to the order repository item. What I usually do is write a Java service that gets all the orders that fit a certain criteria from the repository and then delete them.
David you are correct but honestly I’ve never used those settings. I’d have to look at the code to see what they do. I’ve actually moved away from persisting orders for anonymous users using this mechanism and instead moved to a different method. I’ll need to write a post about that. 🙂
Frank,
I ended up going with a pure cookie based solution for both anonymous and registered users on the site. So now the only thing that gets persisted to the orders table are true orders. I created a Cart Restore servlet to run in the pipeline, only runs once per session. Then made modifications to the cookie manager long with overriding update order. So far working pretty good.
I was taking a look at Hybris the other day and what they have is a cart table and a order table. So they keep these items completely separate which I think makes a nice clean design and data view as well
David,
Your solution sounds something like mine, maybe a lot better. 🙂
That is interesting about Hybris. Hadn’t heard about that platform until now.