Basketpreview cache and user-specific data¶
Ibexa Commerce uses a lot of dynamic data which has to be displayed in the shop:
- basket preview shows the number of products and a list of products
- the name of the customer
- the number of items in the wishlist
To improve the caching and speed up page loading, a special route is used to provide the dynamic data using a REST call.
The REST route¶
silversolutions_session_data is used to send a call to the server to get the updated data for the dynamic attributes.
By default the following attributes are returned:
- the logged-in user
- the basket preview
An event is trigged after the data has been received via REST:
You can subscribe to the event inside a vue app using
1 2 3 4
Extending the REST call¶
The modules section can be used for the project-specific data. It uses a tagged service that has to implement a service via service tag:
mydata is used as a key in the modules section.
Working with HTML fragments¶
Each service implementing
SessionDataInterface can return HTML fragments.
The keys should use the ID of a container inside your site. Ibexa Commerce automatically replaces this container with the indicated HTML.
Example for providing the data in a service:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
The corresponding div in the website needs to use the key
headerLoginDesktop, e.g. as an ID:
1 2 3
Updating existing projects¶
1. Allow accessing cookies via JS:
1 2 3 4 5
pagelayout.html.twig within the header:
3. Add the
routeconfig to the
pagelayout.html.twig at the beginning of the
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
5. Change the Twig block
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18