Page 11 of 17
Re: [RELEASED] Override Engine for OpenCart
Posted: Wed Oct 29, 2014 2:02 am
by JNeuhoff
MrMagoo wrote:Probably I can't understand well how OE works.
Is there an exaustive guide to learn OE?
Thank you.
See our FAQs for
OpenCart 2.0 and
OpenCart 1.5.x for more details.
Re: [RELEASED] Override Engine for OpenCart
Posted: Wed Oct 29, 2014 4:46 am
by MrMagoo
JNeuhoof, I've already read FAQs, but it's not enough for me.
Can be Override Engine an alternative of VQMOD?
OE can override only classes or can override tpl script or css or js?
Re: [RELEASED] Override Engine for OpenCart
Posted: Thu Oct 30, 2014 4:50 pm
by openmandrake
Hi,
I experimented with composer a bit. Now i have a first approach to install opencart (including override engine) via composer. just use the following composer command to install opencart: composer create-project beyondit/opencart ./path/to/installation/directory
I had the idea to create a custom installer for override engine modules, which would simply allow one to install modules via composer, e.g.: composer require vendor/modulename.
Is anybody interessted in this approach? For now i will update the composer approach for all forthcoming releases, to be useable for anybody.
Re: [RELEASED] Override Engine for OpenCart
Posted: Mon Dec 01, 2014 4:34 am
by JNeuhoff
The
Override Engine is now available for the newly released OpenCart 2.0.1.0.
Re: [RELEASED] Override Engine for OpenCart
Posted: Fri Jan 16, 2015 3:57 pm
by kalebwright
Okay, I am new to this extension as of Opencart 2.0.1... and my initial experience has been shakey to say the least.
After purchasing an opencart template I was forced to download this extension in order to use the theme. As we all know refunds are nearly impossible with digital goods so I am stuck to figure this one out, or purchase another template. I am getting an error and am not able to pull up the website at all after installing this extension.
Error follows:
Notice: Array to string conversion in .../system/modification/system/engine/action.php on line 12
Has anyone come across this error? Is there a solution that can be offered?
Re: [RELEASED] Override Engine for OpenCart
Posted: Sat Jan 17, 2015 11:07 pm
by JNeuhoff
This has nothing to do with the Override Engine which you haven't even installed because if it was there'd be no code at line 12 of the system/engine/action.php.
3rd party OpenCart templates often tend to be in conflict with other extensions, Shoppica being one of the worst offenders in this.
Re: [RELEASED] Override Engine for OpenCart
Posted: Sat Jan 17, 2015 11:52 pm
by kalebwright
I have installed this extension... the error is not at /system/engine/action.php but at modifications/system/engine/action.php...
I made the mistake of going to line 12 of the other file too which is a commental line.
I have attempted to do this from 3 fresh opencart installation and each time I have gotten this result BEFORE I activate or install a theme.
I am not using Shoppica, I am using Carera from Themeforest.net.
I guess what I am getting is that there is no help for this extension... as a developer you must remember that our programs only work on statistical guarantees. There will always be a situation where the perfect code for some reason just didn't work. I was just curious as to whether or not we could work together to figure this one out.
I have read the entire thread, I am not the first with a problem with this plug in. I followed the instructions listed exactly as they are here on the site. And your response to my post is very immature & lacking profession.
Re: [RELEASED] Override Engine for OpenCart
Posted: Sun Jan 18, 2015 12:48 am
by JNeuhoff
If the Override Engine were installed on your OpenCart, the first few lines in your system/modification/system/engine/action.php should look like this:
Code: Select all
<?php
/* ---------------------------------------------------------------------------------- */
/* OpenCart Action (with support for the Override Engine) */
/* */
/* Original file Copyright © 2012-2014 by Daniel Kerr (www.opencart.com) */
/* Modifications Copyright © 2014 by J.Neuhoff (www.mhccorp.com) */
/* */
/* This file is part of OpenCart. */
/* */
/* OpenCart is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation, either version 3 of the License, or */
/* (at your option) any later version. */
/* */
/* OpenCart is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with OpenCart. If not, see <http://www.gnu.org/licenses/>. */
/* ---------------------------------------------------------------------------------- */
As you can see there is no code at line 12!
Have you tried to do a refresh of your OCmod modifications in the admin backend after the Override Engine installation? You can do it at
admin > Extensions > Modifications > Refresh button
Re: [RELEASED] Override Engine for OpenCart
Posted: Sun Jan 18, 2015 1:50 am
by kalebwright
That is what the file at /system/engine/action.php shows, you may be misunderstanding the file in question. I have included screenshots so that it may be seen.
Also, I cleared my modifications in OC prior to installing Override Engine but after installing it I have not been able to access my site because of the error.
Have you ever experienced this error?
Line of code in question is
Code: Select all
$parts = explode('/', str_replace('../', '', (string)$route));
Re: [RELEASED] Override Engine for OpenCart
Posted: Sun Jan 18, 2015 3:14 am
by JNeuhoff
OK, I think I know what happened.
You must have installed the original OpenCart and also did the Refresh in the admin > Extensions > Modifications, and then you uploaded the Override Engine afterwards.
Try this: Manually, via FTP (or your local file explorer if testing on a local PC), remove all files and folders (except index.html) from your system/modification. Now you should be able to go into the admin > Extensions > Modifcations and do a Refresh, this will update the files and folders in system/modification with the Override Engine changes embedded in them, too, e.g. in the system/modification/system/engine/action.php.
Re: [RELEASED] Override Engine for OpenCart
Posted: Mon Jan 19, 2015 12:32 am
by her63
Nice work, keep the spirit on. God Bless You All
Re: [RELEASED] Override Engine for OpenCart
Posted: Sat Jan 24, 2015 1:33 am
by kalebwright
Sorry for not posting sooner... I was able to recreate the problem on a test server and the method you advised me to use to clear modifications works! (Even though you probably already knew it would...)
Great for me, however. At least I can resell this theme and get my money back out of it now. I am intrigued by the override extension and look to experiment more with it for my own modifications to OC. Thanks again!
Re: [RELEASED] Override Engine for OpenCart
Posted: Sat Jan 24, 2015 12:44 pm
by meBooks
Thanks for your great extension -- I've just installed the override engine (Override Engine (v6.4.3) for OpenCart 2.0.1.0) and I thought you should know about a couple of minor issues I discovered in the readme.txt.
I followed it closely, as the examples in the readme.txt were want I wanted to do, namely introduce addtional product fields.
However, on creating my override I was getting a "Product not found" error in the front-end when visiting the URL for a valid product -- upon scratching my head for quite a while, I realised I'd taken the readme.txt examples a little too literally, and the model extension example was missing the following line at the end:
i.e.
Code: Select all
<?php
class addon_x_ModelCatalogProduct extends ModelCatalogProduct {
/* override method */
public function getProduct($product_id) {
$product = parent::getProduct( $product_id );
if ($product) {
$sql = "SELECT myfield FROM `".DB_PREFIX.product` ";
$sql .= "WHERE product_id='".(int)$product_id."'";
$result = $this->db->query($sql);
$product['myfield'] = $result->row['myfield'];
} else {
$product['myfield'] = '';
}
}
}
?>
should be:
Code: Select all
<?php
class addon_x_ModelCatalogProduct extends ModelCatalogProduct {
/* override method */
public function getProduct($product_id) {
$product = parent::getProduct( $product_id );
if ($product) {
$sql = "SELECT myfield FROM `".DB_PREFIX.product` ";
$sql .= "WHERE product_id='".(int)$product_id."'";
$result = $this->db->query($sql);
$product['myfield'] = $result->row['myfield'];
} else {
$product['myfield'] = '';
}
return $product;
}
}
?>
Also, the controller example contains the following:
Code: Select all
// modify template file
$template_buffer = str_replace(
'<?php echo $description; ?>',
'<?php echo $description; ?><br /><?php echo $text_myfield; ?>:<?php echo $myfield; ?>'
);
but str_replace requires three parameters, so should actually be:
Code: Select all
// modify template file
$template_buffer = str_replace(
'<?php echo $description; ?>',
'<?php echo $description; ?><br /><?php echo $text_myfield; ?>:<?php echo $myfield; ?>',
$template_buffer
);
Minor quibbles I know but they stumped for a while, and I had to get xdebug out to work out what was going on.
Thanks for a great (and free!) extension.
Re: [RELEASED] Override Engine for OpenCart
Posted: Mon Jan 26, 2015 12:38 am
by JNeuhoff
meBooks:Thanks for bringing that to my attention, I have now corrected the documentation.
Re: [RELEASED] Override Engine for OpenCart
Posted: Tue Feb 03, 2015 9:27 am
by joeri1977
Hi,
I am fairly new to open cart and I just installed the latest version of Open Cart. On the default theme a simple thing I want to do is add the slider to a new module position above the main navigation. I don't want to override any core files so I came across the override engine extension. I am just a little stuck on what files I need to copy over to the override folder (or is it not files I need to copy, but create new (override) files)?
Simply said I want to add a new module position and assign the homepage slider to this position and then call it in the header.tpl.
Best regards,
Joeri.
Re: [RELEASED] Override Engine for OpenCart
Posted: Tue Feb 03, 2015 8:14 pm
by plugables
Why can't override engine be part of OpenCart core?
Re: [RELEASED] Override Engine for OpenCart
Posted: Wed Feb 04, 2015 11:25 am
by mithereal
i can figure out how to load languange strings into a controller but they dont render in prerender only a not found error , the prerender data is there (the divs and markup) but the language strings (in this case tab_stock cannot be found) what am i doing wrong, if i call the parent at the beginning of the function none of my changes take so i call it at the end, theres really no documentation to where to call the parent.
do i call language files from the oveeridden prerender function or is ok to call from the overridden getform function?
Code: Select all
class stock_ControllerCatalogProduct extends ControllerCatalogProduct {
protected function getForm() {
$data['heading_title'] = $this->language->get('heading_title');
$this->load->model('module/stock');
$data['entry_has_option'] = $this->language->get('entry_has_option');
$data['tab_stock'] = $this->language->get('tab_stock');
$this->response->setOutput($this->load->view('catalog/product_form.tpl', $data));
parent::getForm();
}
public function preRender( $template_buffer, $template_name, &$data ) {
switch ($template_name) {
case "catalog/product_form.tpl":
$search ='<li><a href="#tab-option" data-toggle="tab"><?php echo $tab_option; ?></a></li>';
$replace='<li><a href="#tab-stock" data-toggle="tab"><?php echo $tab_stock; ?></a></li> ';
$template_buffer = str_replace(
$search,
$replace,
$template_buffer
);
break;
}
return parent::preRender( $template_buffer, $template_name, $data );
}
Error is Notice: Undefined variable: tab_stock in /srv/http/demo/system/cache/override/admin_view_template_catalog_product_form.tpl on line 34
Re: [RELEASED] Override Engine for OpenCart
Posted: Wed Feb 04, 2015 8:09 pm
by JNeuhoff
mithereal:
Try this:
Code: Select all
class stock_ControllerProductProduct extends ControllerProductProduct {
/* 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');
// modify template file
// ... do whatever is needed to modify the product_form.tpl ....
$template_buffer = str_replace( .... );
// call parent method
return parent::preRender( $template_buffer, $template_name, $data );
}
}
I assume you are using OpenCart 2.x
Re: [RELEASED] Override Engine for OpenCart
Posted: Thu Feb 05, 2015 3:49 am
by mithereal
that works, but i also have a language override in place
product.php
// Additional Entry
$_['tab_stock'] = 'Stock Control';
/* 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');
$this->load->language('catalog/product');
$data['entry_has_option'] = $this->language->get('entry_has_option');
$data['tab_stock'] = $this->language->get('tab_stock');
// modify template file
// ... do whatever is needed to modify the product_form.tpl ....
$template_buffer = str_replace( .... );
// call parent method
return parent::preRender( $template_buffer, $template_name, $data );
}
but in the rendered view i get tab_stock as the string, its like it cannot get the value of $this->language->get('tab_stock'); because it doesnt exist in the current scope.
Re: [RELEASED] Override Engine for OpenCart
Posted: Thu Feb 05, 2015 5:21 am
by mithereal
is there a way to view the overridden class/model/language to make sure my overrides are actually being used