The bake.sh
script is where all the src/Model files came from.
- It calls
bin/cake bake
for every table in the Opencart database, and then makes final adjustments to the generated model classes. - It also generates Abstract classes for each database table - but only if a given class doesn't exist already. These Abstract classes are then made to be the common parent for all table classes baked by CakePHP. If you need to re-generate the abstract classes, delete the individual classes or whole Abstract directories in
PLUGIN/src/Model/Entity
and/orPLUGIN/src/Model/Table
, re-runbake.sh
and restore manual edits, if any, from git. - Finally, it copies custom models from
PLUGIN/tools/copy
. If you have custom models that don't have a database table, they won't be picked up by the loop in step 1, so you have to manually create them inside that folder.
It accepts Opencart version number as argument: 2
or 4
.
-
cd
to a folder with CakePHP application. The application needs to have an Opencart database connection defined inconfig/app.php
orconfig/app_local.php
namedopencart$VERSION-clean
-
Run the
bake.sh
script/var/www/cakephp-opencart/tools/bake.sh $VERSION
$VERSION
must match$VERSION
from the database connection name above.
All changes and adjustments to the model files must be made through this script. No manual edits - this ensures the ability to re-run bake.sh
without fearing to lose edits.