Post by guntis.e » Thu Sep 14, 2017 1:32 am

I'm stuck at this. Can't make event work. It installs ok, but does nothing. It should trigger on cart page load, shouldn't it?

file: admin/controller/extension/myext/cart.php

Code: Select all

<?php
class ControllerExtensionMyextCart extends Controller {
    
    public function install() {
        
        $this->load->model('extension/event');
        
        $code = "myext_cart";
        $trigger = "catalog/view/checkout/cart/before";
        $action = "extension/myext/cart/beforeCartView";
        $this->model_extension_event->addEvent($code, $trigger, $action);
    }

    public function beforeCartView() {
        $this->log->write('ok');
    }

    public function uninstall() {
        $this->load->model('extension/event');
        $this->model_extension_event->deleteEvent('myext_cart');
    }
}

Guntis
ImagePartneris.net


New member

Posts

Joined
Fri Jan 28, 2011 4:20 am

Post by DigitCart » Thu Sep 14, 2017 4:27 am

Hi,
You must add some arguments to your action function, try this:

Code: Select all

public function beforeCartView($route = false, &$data = false){
	$data['heading_title'] = 'New Heading Title';
}
This will change the heading title.

My Extensions / DigitCart


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by guntis.e » Thu Sep 14, 2017 8:12 pm

DigitCart wrote:
Thu Sep 14, 2017 4:27 am
Hi,
You must add some arguments to your action function, try this:

Code: Select all

public function beforeCartView($route = false, &$data = false){
	$data['heading_title'] = 'New Heading Title';
}
This will change the heading title.
This is good point, but after adding paramenters i still do not get any result, it is just not executing:

Code: Select all

 public function beforeCartView(&$route, &$data, &$output) {
        $this->log->write('ok');
    }

Guntis
ImagePartneris.net


New member

Posts

Joined
Fri Jan 28, 2011 4:20 am

Post by guntis.e » Fri Sep 15, 2017 7:41 pm

I found what is wrong. Acording to this issue - if i am triggering frontend, then the action should also be on the frontend.

That way creating file catalog/controller/extension/myext/cart.php with the following code

Code: Select all

<?php
class ControllerExtensionMyextCart extends Controller {
    public function beforeCartView() {
        $this->log->write('ok');
    }
}
helped and now i can get 'ok' in the error log :)

Guntis
ImagePartneris.net


New member

Posts

Joined
Fri Jan 28, 2011 4:20 am
Who is online

Users browsing this forum: No registered users and 51 guests