VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: sandomatyas on November 10, 2018, 21:49:57 PM

Title: Calculate data once, use site wide
Post by: sandomatyas on November 10, 2018, 21:49:57 PM
There is a VirtueMart based site where I need some information about the products which are collected from VM's tables and other external tables/files aswell. These are some pieces of related metadata information and not just the products. E.g: date interval of weekly sales, categories/products which are included in the sale, discount percentage, etc etc. Some of them are not directly connected to VM but I need to display it.
I need these information site-wide like in category view, productdetails view, cart, order emails, some modules or vmcustom plugins, etc.

So the question: What is the best way to collect the information once per pageload (or perhaps per session) but use it in several parts of the site? I want to do this mainly for performance reasons and of course for a more clear code.
Title: Re: Calculate data once, use site wide
Post by: GJC Web Design on November 11, 2018, 10:35:54 AM
something like your own plugin with its own table then fetch/call these values and display
Title: Re: Calculate data once, use site wide
Post by: Studio 42 on November 11, 2018, 12:48:07 PM
You can use Joomla cache as base, you can use it to cache HTML or code(json object, db results for eg.) or use a file cache.
If you need it per pageload, then you can use a static value or array in a class using an instance Id.