Post by Api77 » Sat May 22, 2010 10:38 pm

I am not sure if the topic has not been already discussed. Yestarday I spent a couple of hours searching info about the opencart and shopping solution. The reason I have an order from a client that wants a shop with some special requirements. The main shopping carts that I discussed were magento, opencart, joomla virtumart. As you can guess the chosen cart was opencart due to its well structured code, light and not hosting hungy, intuitive backoffice.

To meet the needs of the client the Opencart has to be modified and the developer that will do the job will have to modify the core code and here is the reason for my post and suggestion. I found one opinion from opencart developer who suggested all modification of the opencart to be putted in a separate folder. Thus the modification could be controlled and they will not hamper the updates to new versions of the opencart. The best practices how the core development team could act together with all volunteer developers are Drupal, Wordpress and Firefox.

If a plug-in concept is implemented in the Opencart this will drive a lot of developers to create a powerful plug-ins and to keep them up to date with the new versions of the Opencart.

The questions are - is it possible to be done? and is it necessary?

Newbie

Posts

Joined
Sat May 22, 2010 6:28 pm


Post by Xsecrets » Sat May 22, 2010 11:45 pm

It has been discussed several times, and it will eventually get there, but it will probably be in the next "Major" version change which will most likely still be a ways out there's probably still going to be more discussion on the best method. Unfortunately as it stands now any changes to the core no matter how you do them will hamper upgrades somewhat.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by JNeuhoff » Sun May 23, 2010 2:31 am

It has been discussed a few times on this forum, but there is no easy solution to this problem. We looked at systems like the Kohana framework and Qphoria looked at the way modifications are applied to the (I think) phpBB, but none of these solutions are satisfying for our purposes. Just imagine the simple scenario of lets say 2 OpenCart contributions, where none is aware of each other, and both happen to modify the same OpenCart core classes, possibly even the same methods. At the moment, we'd have to manually merge the changes from each contribution to the OpenCart classes. However, there already is a clearly defined way for adding new modules, shipping methods, payment methods, or order total modules to OpenCart, without the need to change OpenCart core classes.

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 _Undefined » Tue May 25, 2010 8:50 pm

MyBB has an excellent plugin system. Basically a php file is put in a folder with a set of functions, although in my opinion this should be replaced by a class.

For example, say I wanted to add another content box on the homepage above the latest products box.

Code: Select all

class NewBox
{
    function info()
    {
        return array("NewBox", "Adds a new content box to the homepage");
    }
    
    function is_installed()
    {
        // Check a table or something exists here, which would only be there if the plugin was installed.
        // If a plugin doesn't require installation, the is_installed, install and uninstall functions wouldn't be included in this file.
    }
    
    function install()
    {
        // Add tables etc stuff here.
    }
    
    function uninstall()
    {
        // Remove tables etc stuff here that were added by the install function.
    }
    
    function activate()
    {
        /*
        Modify view and controller files etc here.
        
        A way to do this would possibly use a function like find_replace_file, which would find text in a file, replace it with what is specified, and save the file.
        This would allow any number of mods to make changes to any OC files, and still allow upgrading of the system.
        */
        
        find_replace_file('<div id="content">', '<div class="content2"></div><div id="content">', 'catalog/view/theme/default/template/common/home.tpl');
        // Other call to find_replace_file to add css here etc.
    }
    
    function deactivate()
    {
        // Reverse everything done in the activate function.
        find_replace_file('<div class="content2"></div><div id="content">', '<div id="content">', 'catalog/view/theme/default/template/common/home.tpl');
    }
}
 
The file would be saved as newbox.php, and OC would have an interface on the admin panel to activate/deactivate/install/uninstall based on the current status of the plugin. Another table would keep information on whether plugins are activated or not.

The other segment to MyBB's plugins is a hooks system. This would allow information to be changed live by plugins on each page load with the use of plugins. Something similar to above, but it would be used at runtime.

Code: Select all

$this->plugins->hook("home_display",
    function($htmlcontent)
    {
        $htmlcontent = str_replace('<div class="content2"></div><div id="content">', '<div id="content">', $htmlcontent);
    }
);
 
Obviously lots of code would need to be modified to add the hooking system, but I think it would be worth it.

This would GREATLY open up OpenCart to modifications, and I think it would massively benefit development.

I am currently working on a system myself to do this, as my employer requires a lot of changes to OC, but also requires the most up to date version of OC at all times.

Newbie

Posts

Joined
Tue May 25, 2010 8:24 pm

Post by marcM » Fri Jul 23, 2010 10:49 pm

+1 for plugins & hooks

IMHO, The clean & simple plugin & hook system in Wordpress is a big part of what has made it grow so popular.

Newbie

Posts

Joined
Fri Jul 23, 2010 10:45 pm

Post by Xsecrets » Fri Jul 23, 2010 10:55 pm

well the big thing missing is the hooks. modules work almost identical to what the previous poster mentioned already, the problem being that you cannot do anything other in the alloted slots in right, left, and homepage.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Daniel » Wed Jul 28, 2010 10:24 am

hooks are really just observer patterns. I don't know why people start renaming thing.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by Xsecrets » Wed Jul 28, 2010 11:41 am

Daniel wrote:hooks are really just observer patterns. I don't know why people start renaming thing.
we really don't care what you call them as long as you put them in so we can get get things in there without editing core files.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by jayman » Sat Aug 07, 2010 6:32 am

I will totally agree with needing this implemented into the frame work. It just will allow more people to be willing to contribute extension and mods, let alone having to mess with the core. Plus it makes it a lot quicker to change things around. It's like doing a math problem yes I can use a pencil and paper and write it out, or I can just use a calculator same concept.

I just think that this would be one of the things that could make opencart just that much better, look at wordpress almost everybody uses it if they blog. I would think as the developer of this you would want the same thing for your project.

Daniel, you really have the potential to make opencart the best ecommerce platform on the net, but the only way it will happen is if you listen to people and their requests.

New member

Posts

Joined
Wed Apr 07, 2010 1:32 pm

Post by snakelab » Wed Aug 11, 2010 5:11 am

Hi Folks,

i wonder if a plugin/observer/hook/event/whatever-system is on the roadmap and what priority this feature have?

thanks

User avatar
Newbie

Posts

Joined
Tue Aug 18, 2009 1:55 am

Post by JNeuhoff » Thu Aug 12, 2010 6:10 pm

What would be useful to have install and uninstall methods in the module code, e.g. file admin/controller/module/xxx.php looks like this:

Code: Select all

<?php
class ControllerModuleXXX extends Controller {

	public function index() {
		.......
	}

	public function install() {
		/* module specific installation code */
		/* e.g. creating DB tables */
	}

	public function uninstall() {
		/* module specific uninstall code */
	}

}
?>
And these methods would then be automatically called in the

admin/controller/extension/module.php from its install and uninstall methods.

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 Qphoria » Thu Aug 12, 2010 7:30 pm

JNeuhoff wrote:What would be useful to have install and uninstall methods in the module code, e.g. file admin/controller/module/xxx.php looks like this:

Code: Select all

<?php
class ControllerModuleXXX extends Controller {

	public function index() {
		.......
	}

	public function install() {
		/* module specific installation code */
		/* e.g. creating DB tables */
	}

	public function uninstall() {
		/* module specific uninstall code */
	}

}
?>
And these methods would then be automatically called in the

admin/controller/extension/module.php from its install and uninstall methods.
Wow you are a bit behind the times :)

Welcome to 4 weeks ago:
http://forum.opencart.com/viewtopic.php ... 165#p86477 (2nd bullet under Added)

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by JNeuhoff » Thu Aug 12, 2010 8:06 pm

Wow you are a bit behind the times :)
Just testing whether you are still paying attention :)

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 JAY6390 » Thu Aug 12, 2010 9:25 pm

hehe definitely a welcomed addition to the new cart :)

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 34 guests