I see how to use an event to generate a controller call in OpenCart 2.3.
What I don't see is how to save the data created by the controller call for later use in a view.
How have other people handled this?
I see how to use an event to generate a controller call in OpenCart 2.3.
What I don't see is how to save the data created by the controller call for later use in a view.
How have other people handled this?
Not sure exactly what you want to do here but couldn't you just do something like:
file_put_contents(DIR_CACHE . __CLASS__ . __FUNCTION__ . md5(serialize($this->request->get)) . '.ser', serialize($data));
That would store everything in $data
(which is everything that gets passed to the view) in a flat file named after the class and method and query parameters.
Then, for example, to recall later on a product page, just do:
if (file_exists(DIR_CACHE . __CLASS__ . __FUNCTION__ . md5(serialize($this->request->get)) . '.ser') {
$data = unserialize(file_get_contents(DIR_CACHE . __CLASS__ . __FUNCTION__ . md5(serialize($this->request->get)) . '.ser'));
$this->response->setOutput($this->load->view('product/product', $data));
}
Not sure if that answers your question but could could also just use Opencart's built in cache methods if you wanted it to expire at regular intervals.