Post by JNeuhoff » Thu Feb 05, 2015 5:54 pm

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?';
?>

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JNeuhoff » Thu Feb 05, 2015 7:13 pm

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by mithereal » Fri Feb 06, 2015 12:07 pm

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

User avatar
Newbie

Posts

Joined
Fri Mar 22, 2013 6:16 am

Post by JNeuhoff » Fri Feb 06, 2015 6:42 pm

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

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by mithereal » Sat Feb 07, 2015 1:27 pm

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.

User avatar
Newbie

Posts

Joined
Fri Mar 22, 2013 6:16 am

Post by JNeuhoff » Sat Feb 07, 2015 8:33 pm

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by openmandrake » Wed Feb 11, 2015 6:23 pm

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

Checkout our extensions, or our open source projects


New member

Posts

Joined
Wed Oct 31, 2012 3:05 am

Post by CodeSpace » Thu Feb 26, 2015 4:20 am

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

User avatar
Active Member

Posts

Joined
Mon Aug 06, 2012 9:26 pm

Post by JNeuhoff » Thu Feb 26, 2015 7:21 am

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by CodeSpace » Thu Feb 26, 2015 5:02 pm

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.

User avatar
Active Member

Posts

Joined
Mon Aug 06, 2012 9:26 pm

Post by JNeuhoff » Thu Feb 26, 2015 10:14 pm

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by JonathanBray0292 » Wed Mar 04, 2015 7:20 am

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


Posts

Joined
Wed Mar 04, 2015 7:16 am

Post by satyajit9830 » Sat Mar 28, 2015 9:13 pm

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

Newbie

Posts

Joined
Tue Apr 24, 2012 2:55 am

Post by JNeuhoff » Sun Mar 29, 2015 1:18 am

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

User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by satyajit9830 » Sun Mar 29, 2015 1:20 am

Any hack of fix to resolve this ?

Newbie

Posts

Joined
Tue Apr 24, 2012 2:55 am

Post by JNeuhoff » Sun Mar 29, 2015 2:09 am

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by atnaples » Mon Apr 13, 2015 11:46 pm

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..}

User avatar
New member

Posts

Joined
Thu Dec 11, 2014 7:20 am

Post by JNeuhoff » Thu Apr 16, 2015 1:22 am

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.

MHC Web Design
Override Engine * Integrated VQMod * Multilingual SEO * Instant Option Price Calculator * TrustPilot Reviews * Download Options * Free Download Buttons * Export/Import Tool * Template Switcher PHP/Twig


User avatar
Expert Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by atnaples » Thu Apr 16, 2015 9:22 am

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}

User avatar
New member

Posts

Joined
Thu Dec 11, 2014 7:20 am
Who is online

Users browsing this forum: No registered users and 11 guests