I'm attempting to hook into a function using opencart's event system in order to include a class that automatically updates a product's image and description from a source on the internet.
I've got it successfully firing after the addProduct method in the admin side, but can't seem to get it to fire after a protected method in an extension I've got installed. (Import/Export 3.3)
Here's the relevant code for the install/uninstall routine in my module.
Code: Select all
public function install() {
$this->load->model('extension/event');
$this->model_extension_event->addEvent('jeffrodh_scrapeComics', 'admin/model/catalog/product/addProduct/after', 'module/scrape_comics');
$this->model_extension_event->addEvent('jeffrodh_scrapeComics_01', 'admin/model/tool/export_import/storeProductIntoDatabase/after', 'module/scrape_comics/on_import');
$this->log->write('Installation Successful: Scrape Comics');
}
public function uninstall() {
$this->load->model('extension/event');
$this->model_extension_event->deleteEvent('jeffrodh_scrapeComics');
$this->model_extension_event->deleteEvent('jeffrodh_scrapeComics_01');
$this->log->write('Uninstallation Successful: Scrape Comics');
}
Code: Select all
public function index($data, $product_id) { //Interesting stuff happens }
Code: Select all
public function on_import($route, $product) { //Interesting stuff happens }
Additionally, I don't really understand where the $product_id is being passed FROM in the first example. I plugged in variables from the admin/model/catalog/product.php and it just worked. Therefore, I'm not certain that I'm going to be able to successfully pass variables from the other model into this event given that the storeProductIntoDatabase method is protected within its parent class. Documentation is almost nonexistent, and if someone would be willing to pass along some knowledge, I think this could really benefit the community.
Many thanks in advance.