Dynamic Menu Generation in Prestashop

May 30, 2016 Alex Simonchik Prestashop
Dynamic Menu Generation in Prestashop

The larger a store becomes, the more complicated its catalog structure is. Simultaneously the store menu gets more complicated as well. Database queries get more complex and more time is needed for the page generation.

Server-side caching (NGINX in our case) and AJAX requests to the submenu items can be used as one of the ways to optimize the rendering process.

The idea is that server pulls out submenu items on a separate request. According to such an approach, only a top-menu level is generated during the page load. While opening a submenu item, the server checks whether there is a cached element and if necessary, generates it and sends to the client. Cash invalidation is not considered here, as this process should be triggered by the catalog structure change.

And here is the PHP Code, which generates static content. sendStaticJSON() function just saves already generated data into the cache storage and sends it to the client. We haven’t cluttered up the code with functions, not related to cashing.



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *