Reputation: 55
I'm working on a website I didn't make in the first place. It's made in 2 parts: the presentation website, and the OpenCart for the e-commerce part.
I need to use some functions of OpenCart, especially to have an access to the main tools (cart, price of the items in the cart ...) in the presentation website (not in the OpenCart template).
So I was wondering if there is any way I can load OpenCart and it's functions, without loading the template when I don't need it.
I know it may sound counter intuitive and may rise the page load time, but I don't have much choice, given the time I have to do this and the experience I lack with OpenCart.
EDIT: Okay so I added this at the bottom of the index.php file of open cart:
if($_GET['module'] == 'website') {
include('website/index.php');
} else {
// Output
$response->output();
}
So in theory, OpenCart is loaded onto my website. But my guess in that output() calls the template AND it's controller, so I don't have access to the variables I need: $login, $text_login, $cart, $checkout ... the toolbox variables. I guess I need to call the controller, but I have no idea what controller is used for what variable... if you have an idea, I would be really thankful.
Thanks, Antoine
Upvotes: 0
Views: 228
Reputation: 15151
This will require quite a bit of work. You will essentially need to duplicate the index.php file in the catalog side and not run the final piece of the code, namely this
// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance'));
// Router
if (isset($request->get['route'])) {
$action = new Action($request->get['route']);
} else {
$action = new Action('common/home');
}
// Dispatch
$controller->dispatch($action, new Action('error/not_found'));
and then you can set up your own actions to show code etc or load the necessary classes directly
Upvotes: 2