Post by petsoukos » Fri Sep 04, 2015 10:41 pm

Hi there,

I'm trying to create a Facebook register/login extension for our shop, but need some help with the event system.

In the file catalog/controller/account/login.php inside the validate() method there's this line:
$this->event->trigger('pre.customer.login');
and this:
$this->event->trigger('post.customer.login');

What code gets executed when this even triggers?

Newbie

Posts

Joined
Fri Nov 08, 2013 5:14 am

Post by petsoukos » Wed Sep 09, 2015 8:45 pm

Anyone? Should I worry about the event system? Is it necessary for what I'm trying to accomplish?

Newbie

Posts

Joined
Fri Nov 08, 2013 5:14 am

Post by qahar » Fri Sep 18, 2015 2:17 pm

petsoukos wrote:In the file catalog/controller/account/login.php inside the validate() method there's this line:
$this->event->trigger('pre.customer.login');
and this:
$this->event->trigger('post.customer.login');

What code gets executed when this even triggers?
From the docs this is how to register event:

Code: Select all

$this->model_extension_event->addEvent('my_module', 'post.customer.login', 'folder/file/method');
What code executed is depend on what action is registered for the triggered event.
To look all registered event you can look at database table 'event'.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by petsoukos » Sun Oct 11, 2015 5:13 am

qahar wrote: From the docs this is how to register event:

Code: Select all

$this->model_extension_event->addEvent('my_module', 'post.customer.login', 'folder/file/method');
What code executed is depend on what action is registered for the triggered event.
To look all registered event you can look at database table 'event'.
The event table is empty.
So, the triggers are there for other developers to execute their custom code?

eg. when the post.customer.login triggers, my 'extension' can execute something?

Newbie

Posts

Joined
Fri Nov 08, 2013 5:14 am

Post by qahar » Sun Oct 11, 2015 2:44 pm

petsoukos wrote:The event table is empty.
So, the triggers are there for other developers to execute their custom code?

eg. when the post.customer.login triggers, my 'extension' can execute something?
Yes, the events is designed for developer who need to do an action or change specific Event data.
But to do some action when Event triggered, it's simple and handy feature compared to modification (ocmod/vqmod)

Even thought OpenCart have this event, it's still not covering all modification requirement.

Let say I have extension that offering multi-language url alias. I can use event to grab current alias on save and put language code prefix. Change from my-link to en-my-link or in Indonesian id-my-link then save it to correct database in my Event code.

But to provide completely custom multi-language url alias with user input, Event can't help.
We need to use modification ocmod/ vqmod to create new multi-language url-alias input at product page, than modificate front seo_url.php to ensure the multi language url alias is not just mapped to corect product but also change the site language to the correct language.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia
Who is online

Users browsing this forum: No registered users and 2 guests