Page 16 of 17

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Dec 06, 2016 11:24 pm
by JNeuhoff
I think this should work:

Code: Select all

<?php
class add_convert_coin_menu_ControllerCommonColumnLeft extends ControllerCommonColumnLeft {
	 public function preRender( $template_buffer, $template_name, &$data ) {
			if ($template_name != 'common/column_left.tpl') {
				 return parent::preRender( $template_buffer, $template_name, $data );
			}

			$this->load->language('common/column_left');

			if ($this->user->hasPermission('access', 'convert/coin')) {
				$convert_coin_menu = array(
					'name'     => $this->language->get('text_convert_coin'),
					'href'     => $this->url->link('convert/coin', 'token=' . $this->session->data['token'], true),
					'children' => array()
				);
				$sales_menu = null;
				foreach ($data['menus'] as $i=>$menu) {
					if ($menu['id']=='menu-sale') {
						$sales_menu = $menu;
						$sales_menu['children'][] = $convert_coin_menu;
						$data['menus'][$i] = $sales_menu;
						break;
					}
				}
				if (!$sales_menu) {
					$sales_menu = array(
						'id'       => 'menu-sale',
						'icon'	   => 'fa-shopping-cart', 
						'name'	   => $this->language->get('text_sale'),
						'href'     => '',
						'children' => array( $convert_coin_menu )
					);
					$data['menus'][] = $sales_menu;
				}
			}

			return parent::preRender( $template_buffer, $template_name, $data );
	 }
		
?>

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Dec 07, 2016 12:56 am
by keraknasi
JNeuhoff wrote:I think this should work:

Code: Select all

<?php
class add_convert_coin_menu_ControllerCommonColumnLeft extends ControllerCommonColumnLeft {
	 public function preRender( $template_buffer, $template_name, &$data ) {
			if ($template_name != 'common/column_left.tpl') {
				 return parent::preRender( $template_buffer, $template_name, $data );
			}

			$this->load->language('common/column_left');

			if ($this->user->hasPermission('access', 'convert/coin')) {
				$convert_coin_menu = array(
					'name'     => $this->language->get('text_convert_coin'),
					'href'     => $this->url->link('convert/coin', 'token=' . $this->session->data['token'], true),
					'children' => array()
				);
				$sales_menu = null;
				foreach ($data['menus'] as $i=>$menu) {
					if ($menu['id']=='menu-sale') {
						$sales_menu = $menu;
						$sales_menu['children'][] = $convert_coin_menu;
						$data['menus'][$i] = $sales_menu;
						break;
					}
				}
				if (!$sales_menu) {
					$sales_menu = array(
						'id'       => 'menu-sale',
						'icon'	   => 'fa-shopping-cart', 
						'name'	   => $this->language->get('text_sale'),
						'href'     => '',
						'children' => array( $convert_coin_menu )
					);
					$data['menus'][] = $sales_menu;
				}
			}

			return parent::preRender( $template_buffer, $template_name, $data );
	 }
		
?>
nice, it works. thanks for you fast response to solve my problem

Re: [RELEASED] Override Engine for OpenCart

Posted: Sat Jul 08, 2017 4:42 pm
by arnocn
hello,
I use OC2.0.3.1, i move my site to the new server today, before the move, the site worked fine. but in the new server, i get this error:
Fatal error: Class 'Factory' not found in /the site root/index.php on line 54

the code of the line 54 and 55 in index.php is:
$config = $factory->newConfig();
$registry->set('config', $config);

Anyone know what may cause the problem?
Thanks in advance.

Re: [RELEASED] Override Engine for OpenCart

Posted: Sun Jul 09, 2017 12:20 am
by JNeuhoff
Make sure the file 'system/engine/factory.php' is there, and that the system/startup.php includes this file.

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Jul 11, 2017 7:13 pm
by arnocn
@JNeuhoff
Hi, thanks for your reply.
I checked, the file 'system/engine/factory.php' is there.
and in file system/startup.php, i can see this code:
require_once(DIR_SYSTEM . 'engine/factory.php');

The site was working fine before i move it to the new server.
The problem only exist on the new server.

Any more suggestion?

Thanks!

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Jul 11, 2017 10:39 pm
by JNeuhoff
See my PM.

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Jul 12, 2017 12:40 am
by arnocn
Hi,

Thank you for your kind reply.
The problem is solved now! I realized there is mistake in file config.php and admin/config.php. :-[
I did not write correct folder/root, and after i correct it, everything is working fine now.

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Dec 05, 2017 9:55 pm
by Dutch_guy
Hope that you can help. I have bought a template which uses the override engine.

Now I have problem with displaying the Google Base feed. The feed fails to validate at Google, because the feed begins with one space befor the "<?xml version="1.0" encoding="UTF-8" ?>" line.

I suspect that it has to do with the override engine, since I don't have this with other shops. Also checked all the files for the well known BOM problem, but they are all fine.

Even if I delete everything in the google_base.php controller file, it still gives me that empty space.

Any idea's about this?

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Dec 05, 2017 10:23 pm
by JNeuhoff
Dutch_guy wrote:
Tue Dec 05, 2017 9:55 pm
Hope that you can help. I have bought a template which uses the override engine.

Now I have problem with displaying the Google Base feed. The feed fails to validate at Google, because the feed begins with one space befor the "<?xml version="1.0" encoding="UTF-8" ?>" line.

I suspect that it has to do with the override engine, since I don't have this with other shops. Also checked all the files for the well known BOM problem, but they are all fine.

Even if I delete everything in the google_base.php controller file, it still gives me that empty space.

Any idea's about this?
I just tested it on an OpenCart 3.0.2.0 with Override Engine, and the google_base XML feed works as expected, no unexpected leading blanks. Hence I am unable to reproduce your error. If you send me a PM with your FTP and OpenCart login details then I can take a quick look at it.

Re: [RELEASED] Override Engine for OpenCart

Posted: Tue Dec 05, 2017 10:42 pm
by Dutch_guy
Yes, you are right. Just tested it in a clean 2.3.0.2. site and indeed no leading blanks. I guess I will have to look further. Do you maybe have any other idea's? It happens to all the feeds.

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Dec 06, 2017 2:31 am
by Dutch_guy
Solved it. A file from the template in the override folder had a blink line as the last line.

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Jan 19, 2018 12:00 am
by Dutch_guy
Upon testing I stumble upon an error on the last step of checking out (step 6). It gives me the error:

Notice: Cannot find model class file for path 'shipping/free' in /home/admin/domains/mydomain.nl/public_html/website/system/engine/factory.php on line 517

It shows this on all shipping method's. I'm using OpenCart 2.3.0.2.

I can understand the error, because the path should be: extension/shipping/free.

Any idea how I can debug this?

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Jan 19, 2018 12:54 am
by JNeuhoff
I think you must have modified something with your checkout sequence causing this error.

Have you modified the catalog/model/extension/shipping/free.php ?

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Jan 19, 2018 1:45 am
by Dutch_guy
No, haven't modified that. Also the error is with each shipping method. Also compared this file with a clean 2.3.0.2 version, they are the same. Also turned off all modifications, but still the error. Any idea's?

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Jan 19, 2018 2:15 am
by JNeuhoff
If you send me a PM with your OpenCart and FTP login details then I can look at it.

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Jan 19, 2018 10:11 pm
by JNeuhoff
OK, I narrowed it down: There is a bug in file

system/pdf_invoice_pro.ocmod.xml

on line 59.

This ocmod xml script modifies the catalog/controller/checkout/confirm.php, to load the 'shipping/free' model which doesn't exist in OC 2.3.0.2. It looks like this extension hasn't been ported to OC 2.3.0.2, rather, it is for previous 2.0.x versions.

Get the proper extension for the OC 2.3.0.2 version, or disable this extension.

The Override Engine itself is fine, and reported the error correctly.

Re: [RELEASED] Override Engine for OpenCart

Posted: Sat Jan 20, 2018 2:53 am
by Dutch_guy
Thanks a lot! Very kind of you!

I completely forgot to disable those ocmod's to see if there was an error with one of them.

Thanks again!

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Aug 01, 2018 1:56 pm
by Ilya Heifetz
Hello guys,
In the core controller there is a code that executes some method of the model. For example, I would like this method not to be executed, or another argument passed to it. How can I achieve this by using override feature? As I understand it, the code in the overridden controller will simply execute after the code in the core controller, but it is not able to completely cancel and replace the code execution in the core controller.

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Aug 02, 2018 11:25 pm
by JNeuhoff
Ilya Heifetz : I don't think you quite understand the concepts of object-oriented programming. Take a look at this little tutorial. And then the brief examples here.

Basically, you can override your method in an extended model class. And whenever the model instance is created, it will use the extended class. Whenever its method is invoked, it will first call the overridden method. From there, you may optionally call the parent method.

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Nov 20, 2020 2:52 am
by egoriy33
Wrote addon for product search controller but override engine returns {theme}/template/product/buyclick_form.twig as template_name instead of {theme}/template/product/search.twig
My code is the following:

Code: Select all

class addon_1_ControllerProductSearch extends ControllerProductSearch{
   public function preRender( $template_buffer, $template_name, &$data ) {
      print($template_name);exit;
   }
}
Got stuck! Please Help!