Reputation: 899
I need to call in checkout/confirm.tpl file a custom function that i've made in controller/product.php
what's the best way to make this?
i've tried this, but doesn't work:
$productController = $this->load->model('product/product');
$productController->customFunction();
Upvotes: 6
Views: 15021
Reputation: 148
in laravel its so simple just write Controller::call('ApplesController@getSomething');
but there i cant made better than this
$config = new Config();
// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->setCompression($config->get('config_compression'));
$this->registry->set('response', $response);
$action = new Action('product/ready');
$controller = new Front($this->registry);
$controller->addPreAction(new Action('common/maintenance'));
$controller->addPreAction(new Action('common/seo_url'));
$controller->dispatch($action, new Action('error/not_found'));
$response->output();
in this case its well call product/ready
Upvotes: -1
Reputation: 31
$this->load->controller('sale/box',$yourData);
To call ShipmentDate()
function of box Controller
$this->load->controller('sale/box/ShipmentDate',$yourData);
Upvotes: 3
Reputation: 148
yes i find the right answer finally!!! sorry for last bad answer
class ControllerCommonHome extends Controller {
public function index() {
return $this->load->controller('product/ready');
}
}
Upvotes: 7
Reputation: 31
May be something like this could help you (or anyone who's interested)
// Load seo pro
require_once(DIR_CATALOG."/controller/common/seo_pro.php"); // load file
$seoPro = new ControllerCommonSeoPro($this->registry); // pass registry to constructor
$url = HTTP_CATALOG . $seoPro->rewrite(
$this->url('information/information&information_id=' . $result['information_id'])
);
Upvotes: 2
Reputation: 16065
$productController = $this->load->model('product/product');
controller()
in class Loader
- which is not (luckily)So let's say your controller is CatalogProductController
and the method you want to invoke is custom()
- in this case accessing this URL
http://yourstore.com/index.php?route=catalog/product/custom
you will make sure that the custom()
method of CatalogProductController
is invoked/accessed.
You can access such URL in many ways - as a cURL request, as a link's href or via AJAX request, to name some. In a PHP scope even file_get_contents()
or similar approach will work.
(*) By shouldn't I mean that it is (unfortunately) possible in OpenCart but such abuse is against MVC architecture.
Upvotes: 4