Post by JNeuhoff » Tue Dec 06, 2016 11:24 pm

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 );
	 }
		
?>

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by keraknasi » Wed Dec 07, 2016 12:56 am

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

Newbie

Posts

Joined
Tue Nov 22, 2016 11:36 pm

Post by arnocn » Sat Jul 08, 2017 4:42 pm

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.

Newbie

Posts

Joined
Sat Jul 08, 2017 4:40 pm

Post by JNeuhoff » Sun Jul 09, 2017 12:20 am

Make sure the file 'system/engine/factory.php' is there, and that the system/startup.php includes this file.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by arnocn » Tue Jul 11, 2017 7:13 pm

@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!

Newbie

Posts

Joined
Sat Jul 08, 2017 4:40 pm

User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by arnocn » Wed Jul 12, 2017 12:40 am

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.

Newbie

Posts

Joined
Sat Jul 08, 2017 4:40 pm

Post by Dutch_guy » 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?

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by JNeuhoff » Tue Dec 05, 2017 10:23 pm

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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Dutch_guy » Tue Dec 05, 2017 10:42 pm

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.

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by Dutch_guy » Wed Dec 06, 2017 2:31 am

Solved it. A file from the template in the override folder had a blink line as the last line.

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by Dutch_guy » Fri Jan 19, 2018 12:00 am

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?

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by JNeuhoff » Fri Jan 19, 2018 12:54 am

I think you must have modified something with your checkout sequence causing this error.

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

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Dutch_guy » Fri Jan 19, 2018 1:45 am

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?

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by JNeuhoff » Fri Jan 19, 2018 2:15 am

If you send me a PM with your OpenCart and FTP login details then I can look at it.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JNeuhoff » Fri Jan 19, 2018 10:11 pm

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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Dutch_guy » Sat Jan 20, 2018 2:53 am

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!

Image

Free & Paid extensions from Think Twice | Opencart | Hulpmiddelen voor ouderen


Active Member

Posts

Joined
Tue Feb 21, 2012 5:56 pm


Post by Ilya Heifetz » Wed Aug 01, 2018 1:56 pm

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.

Newbie

Posts

Joined
Wed Apr 26, 2017 2:32 pm

Post by JNeuhoff » Thu Aug 02, 2018 11:25 pm

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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by egoriy33 » Fri Nov 20, 2020 2:52 am

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!

Newbie

Posts

Joined
Fri Nov 20, 2020 2:47 am
Who is online

Users browsing this forum: No registered users and 13 guests