Page 12 of 16

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 05, 2015 5:54 pm
by JNeuhoff
mithereal:

Create an override language file at override/stock/catalog/language/english/product/product.php with:

Code: Select all

<?php
// overridden and/or new language strings
$_['tab_stock']        = 'Stock Control';
$_['entry_has_option'] = 'Has Option?';
?>

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 05, 2015 7:13 pm
by JNeuhoff
mithereal wrote:is there a way to view the overridden class/model/language to make sure my overrides are actually being used
Yes, it's all in the override directory. The modified template files (*.tpl) can be seen at system/cache/override/*.tpl. Also, if more than one addon happen to extend the same controller or model class, you can see the changes in system/cache/override, too.

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Feb 06, 2015 12:07 pm
by mithereal
I have exactly that here are the contents of override/stock/admin/language/english/catalog/product.php and override/stock/admin/language/english/product/product.php

Code: Select all

<?php
// Additional Entry
$_['entry_has_option']               = 'Has Options';
$_['tab_stock']                      = 'Stock';
?>
and am calling in prerender like

Code: Select all


   /* overridden method, always called before the final rendering */
   public function preRender( $template_buffer, $template_name, &$data ) {
      if ($template_name != 'catalog/product_form.tpl') {
         return parent::preRender( $template_buffer, $template_name, $data );
      }
   
      // add new controller variables
      $this->load->model('module/stock');
      $data['entry_has_option'] = $this->language->get('entry_has_option');
      $data['tab_stock'] = $this->language->get('tab_stock');
  return parent::preRender( $template_buffer, $template_name, $data );
      }
it only shows tab_stock in the view whereas

Code: Select all


   /* overridden method, always called before the final rendering */
   public function preRender( $template_buffer, $template_name, &$data ) {
      if ($template_name != 'catalog/product_form.tpl') {
         return parent::preRender( $template_buffer, $template_name, $data );
      }
   
      // add new controller variables
      $this->load->model('module/stock');
      $data['entry_has_option'] = $this->language->get('entry_has_option');
      $data['tab_stock'] = "stock";
shows stock

Re: [RELEASED] Override Engine for OpenCart

Posted: Fri Feb 06, 2015 6:42 pm
by JNeuhoff
mithereal:

Make sure you also load the language files before using them:

Code: Select all

       /* overridden method, always called before the final rendering */
       public function preRender( $template_buffer, $template_name, &$data ) {
          if ($template_name != 'catalog/product_form.tpl') {
             return parent::preRender( $template_buffer, $template_name, $data );
          }
       
          // add new controller variables
          $this->load->language( 'catalog/product' );
          $data['entry_has_option'] = $this->language->get('entry_has_option');
          $data['tab_stock'] = $this->language->get('tab_stock');
          return parent::preRender( $template_buffer, $template_name, $data );
      }

Re: [RELEASED] Override Engine for OpenCart

Posted: Sat Feb 07, 2015 1:27 pm
by mithereal
i tried copying your code exactly still nogo. also do the models need to call parent i am assuming so correct me if im wrong.
also do i need to call the parent on every overridden method, say for ex i need to overwrite the edit and getform method, edit calls the getform method do i only need to call parent in the edit method after getform returns or do i need to retern parent on every method the instructions say every method, i am returning from every method, i just wanna be sure.
also i can see my changes on the cached tpl file but not any other files in the cache, are these files cached only if 2 or more mods override the same methids? is there really any reason to override methods such as getform or is it better to just put all the newly created logic in the prerender.
i cant for the life of me figure out why the language files arent loading correctly, if i remove the <?php from the beginning of the language i get output to the screen with the new strings so i am assuming with the php statement they would be getting loaded correctly, but when i dump the language varibles i getonly the origional lang file this is the only mods ive made to your code.

Code: Select all

 /* overridden method, always called before the final rendering */
       public function preRender( $template_buffer, $template_name, &$data ) {
          if ($template_name != 'catalog/product_form.tpl') {
             return parent::preRender( $template_buffer, $template_name, $data );
          }
       
          // add new controller variables
          $this->load->language( 'catalog/product' ); 
          var_dump($this->language);
          $data['entry_has_option'] = $this->language->get('entry_has_option');
          $data['tab_stock'] = $this->language->get('tab_stock');
          return parent::preRender( $template_buffer, $template_name, $data );
      }
when i get this figured out im going to make a writeup so its easier for noobs, it seems simple but the language addons just are frustrating.

Re: [RELEASED] Override Engine for OpenCart

Posted: Sat Feb 07, 2015 8:33 pm
by JNeuhoff
mithereal: Send me a PM with a zipped copy of all your override files, and I'll take a look at them.

As regards cached file in system/cache/override: Only templates are cached, and extended classes which were modified by multiple 3rd party addons.

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Feb 11, 2015 6:23 pm
by openmandrake
Dear all,

how to override a validate() Method inside a Controller "correctly"? Since all $error members are always private inside the Standard Controllers, an overriden validate Method has no access to the error array... e.g.: https://github.com/opencart/opencart/bl ... gister.php

For now my only solution to that is replacing the private with a protected keyword with vqmod, which is not a good approach. Has anybody a better solution?

best,
Stefan

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 26, 2015 4:20 am
by CodeSpace
What do this methode:

Code: Select all

private function findLatestFileDate( $file, $modFiles )
Just compare dates and have no return ;)

Since the default language data isn´t longer default.php, the loading default lang will not work.

Code: Select all

public function loadLanguage( $path ) 

Code: Select all

$filepath = $default. '/' . $path . '.php';
this will load english/german.php ~ englisch/{LANG}.php
Thats doesnt work

And the methode

Code: Select all

        public function newLanguage( $languageDirectory ) {
        
		return $this->newSystemClass( 'library/language.php', array( $languageDirectory, $this ) );
	}
need a

Code: Select all

$this->language_data['directory'] = $languageDirectory;
??

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 26, 2015 7:21 am
by JNeuhoff
You are right about the findLatestFileDate:

It should have a

Code: Select all

return $date;
at the end of that method.

As regards language files: In more recent OpenCart versions, e.g. 2.0.1.1, it uses something like this:

language/english/default.php
language/english/*/*.php
language/german/*/default.php
language/german/*/*.php

which is correctly handled buy the loadLanguage method.

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 26, 2015 5:02 pm
by CodeSpace
JNeuhoff wrote: As regards language files: In more recent OpenCart versions, e.g. 2.0.1.1, it uses something like this:

language/english/default.php
language/english/*/*.php
language/german/*/default.php
language/german/*/*.php

which is correctly handled buy the loadLanguage method.
ok, i´m testing it with 2.0.1.2.

But the change for 2.0.1.2 should be simple.

Code: Select all

        if($directory == $path){
            $filepath = $default . '/' . $default . '.php';
        }else{
            $filepath = $default . '/' . $path . '.php';
        }
in index.php replace

Code: Select all

$language->load('default');
with

Code: Select all

$language->load($languages[$code]['directory']);
admin/index.php is similar.

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Feb 26, 2015 10:14 pm
by JNeuhoff
Well yes, thanks for this.

Notice I haven't yet released the Override Engine for 2.0.1.2 because 2.0.1.2 is still under development.

Re: [RELEASED] Override Engine for OpenCart

Posted: Wed Mar 04, 2015 7:20 am
by JonathanBray0292
Hi

I've installed the override for opencart 2.0.1.1 and it appears not to be working. I get the errors below...

Notice: Undefined variable: text_welcome in /home/harrisonsint/public_html/catalog/view/theme/eclipsehome2green/template/common/header.tpl on line 164

Notice: Undefined variable: categories1 in /home/harrisonsint/public_html/catalog/view/theme/eclipsehome2green/template/common/header.tpl on line 329Warning: Invalid argument supplied for foreach() in /home/harrisonsint/public_html/catalog/view/theme/eclipsehome2green/template/common/header.tpl on line 329

Re: [RELEASED] Override Engine for OpenCart

Posted: Sat Mar 28, 2015 9:13 pm
by satyajit9830
Fatal error: Uncaught exception 'ReflectionException' with message 'Class ControllerAccountRegister-seller does not exist'
When url is "http://www.sevakart.com/index.php?route ... ter-seller"

Now, when i m removing dash from register-seller term, and renaming the file from register-seller.php to registerseller.php
Its working fine.

Please help me to overcome this issue

Re: [RELEASED] Override Engine for OpenCart

Posted: Sun Mar 29, 2015 1:18 am
by JNeuhoff
This is in violation with the OpenCart naming conventions.

Your route should be: account/register_seller

Your class file name and path should be: catalog/controller/account/register_seller.php

The class name should be: ControllerAccountRegisterSeller

Re: [RELEASED] Override Engine for OpenCart

Posted: Sun Mar 29, 2015 1:20 am
by satyajit9830
Any hack of fix to resolve this ?

Re: [RELEASED] Override Engine for OpenCart

Posted: Sun Mar 29, 2015 2:09 am
by JNeuhoff
No hack for this, you can't use '-' in a class name, it's against PHP rules. A valid class name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

Re: [RELEASED] Override Engine for OpenCart

Posted: Mon Apr 06, 2015 9:10 pm
by JNeuhoff
The Override Engine is now available for OpenCart 2.0.2.0

Re: [RELEASED] Override Engine for OpenCart

Posted: Mon Apr 13, 2015 11:46 pm
by atnaples
guys, i put comments:

- you did not update language support for orders and vouchers
- modifications works from previous version, but in current does not work with {... file list..}

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Apr 16, 2015 1:22 am
by JNeuhoff
atnaples wrote:guys, i put comments:

- you did not update language support for orders and vouchers
- modifications works from previous version, but in current does not work with {... file list..}
Your post is so vague and lacks details I am going to ignore it.

Re: [RELEASED] Override Engine for OpenCart

Posted: Thu Apr 16, 2015 9:22 am
by atnaples
catalog\model\checkout\order.php and voucher (2.0.2.* beta and RC it's wrong):

$language = new Language($order_info['language_directory']);
$language->load('default');

if i am right, it should be:

$language = $this->factory->newLanguage($order_info['language_directory']);
$language->load($order_info['language_directory']);

********

modification.php for 2.0.2.* does not recognize{}, for ex: path=".../{name1,name2}