Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

Storefront, admin panel and project folders

An OpenCart shop is two separate applications that share one database: the storefront for customers and the admin panel for staff. Knowing which folder belongs to which application is the first thing needed to find any file.

Project folders

shop/
├── admin/            admin panel application
├── catalog/          storefront application
├── extension/        extensions — your code lives here
│   └── opencart/     built-in modules, payment and shipping methods
├── image/            product pictures and their resized copies
├── system/           the core: engine, libraries, storage
├── config.php        storefront configuration
└── index.php         storefront entry point

The admin panel has its own entry point admin/index.php and its own admin/config.php.

Two applications

ApplicationFolderAddressWho uses it
Storefrontcataloghttp://shop.test/Customers
Admin paneladminhttp://shop.test/admin/Staff

Storefront code cannot be called from the admin panel and vice versa. If both need the same thing, for example a model that reads your table, the file is written twice — once in each application.

Inside an application

catalog and admin are built the same way:

catalog/
├── controller/       page logic
├── model/            database queries
├── view/template/    Twig templates
└── language/en-gb/   texts for each language

Files of one page have the same path in each folder: the controller catalog/controller/product/product.php uses the template catalog/view/template/product/product.twig and the language file catalog/language/en-gb/product/product.php.

The system folder

FolderWhat is in it
system/engineBase classes: controller, model, loader, registry
system/libraryLibraries: cart, customer, mail, cache, database
system/configDefault settings of the engine
system/storageCache, logs, sessions, uploads

The error log is the file system/storage/logs/error.log. It is also shown in the admin panel: System → Maintenance → Error Logs.

Configuration files

config.php and admin/config.php contain constants — fixed values available in any file:

// config.php
define('HTTP_SERVER', 'http://shop.test/');
define('DIR_APPLICATION', '/var/www/shop/catalog/');
define('DIR_EXTENSION', '/var/www/shop/extension/');
define('DIR_STORAGE', '/var/www/shop/system/storage/');
define('DB_DATABASE', 'shop');
define('DB_PREFIX', 'oc_');

DB_PREFIX is the prefix of every table name: the products table is called oc_product. In code the table is always written as DB_PREFIX . "product".

Common mistake

A file is created in catalog/controller/..., but the address is opened under /admin/ — and the page is not found. The storefront and the admin panel do not see each other's files. Decide first who the page is for: a customer page goes into catalog, a staff page into admin.

Thanks for reading!

Donate to the site — we work hard for you.