5

Is there a way for developers to modify controller and model methods in Opencart without having to touch the core files? Much like the way WP has the functions.php file where you can modify the guts of WP without worrying about future upgrades overwriting your code.

Here are some examples which I think every developer needs to have in their Opencart toolkit:

  • The ability to update values
  • Run custom SQL queries
  • Update logic of the program layer
  • Extend the system further
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
enchance
  • 29,075
  • 35
  • 87
  • 127

2 Answers2

1

Take a look at vQmod. This is the primary way that is used by most developers so as not to modify core code

Jay Gilford
  • 15,141
  • 5
  • 37
  • 56
  • 1
    vQmod is great but it has this _hacky_ feel to it I don't quite approve of. Especially since it uses XML when XML was designed for data transfer and not code storage. – enchance Oct 16 '12 at 18:33
  • A fair comment, but it's been largely adopted by the OC community on the whole and is the least intrusive method at present – Jay Gilford Oct 16 '12 at 20:37
0

I would suggest to modify the core minimally so that it can be extended easily. And for anyone who is too late already, below an example to upgrade a modified core from 2.0.2.0 to master: (otherwise I'd suggest forking opencart and using rebase!)

git clone https://github.com/opencart/opencart
cd opencart
git checkout 2.0.2.0 #insert tag with your current version. Mine was 2.0.2.0
cd upload

#Note: sed strips paths for 'upload/' (opencart)
git diff 2.0.2.0 master > ~/patch-to-newest-version.diff | sed "s/+++ b\/upload\//+++ b\//" | sed "s/--- a\/upload\//--- a\//"
#       I chose ^master^ but you'd better use a stable version.

cd to-your-modified-(opencart)core
patch -p1 < ~/patch-to-newest-version.diff

#..time to resolve the conflicts.. hopefully not much. Good luck.

(if anyone knows a better way to patch a modified core, please comment. Especially because it is not nice to keep working in a '/upload' folder... use a sparse checkout or s/t?

twicejr
  • 1,319
  • 3
  • 13
  • 21