Encodera

Thanks for reading!

Donate to the site — we work hard for you.

Contents

Project folders

The root of an installed shop has about two dozen folders. You do not need to remember all of them: you write your code in two, and a few more are worth knowing to find logs, the cache and class sources.

The shop root

shop/
├── admin437xyz/     the back office
├── app/             Symfony settings, parameters.php
├── bin/             the console: bin/console
├── classes/         legacy core classes: Product, Cart, Order
├── config/          constants and settings, defines.inc.php
├── controllers/     legacy core controllers
├── img/             product and category images
├── mails/           email templates
├── modules/         modules — your code goes here
├── override/        overrides of core classes
├── src/             the new Symfony core
├── themes/          themes
├── translations/    translations
├── upload/          files uploaded by customers
├── var/             cache and logs
├── vendor/          Composer libraries
└── webservice/      the web service entry point

Where your code goes

FolderWhat you do there
modules/acmehelloWrite the module
themes/acmeMake a child theme

Everything else belongs to the engine. Files in classes, controllers, src and in the classic theme may and should be read, but not edited.

Where to find the sources

When a module calls Product::getPriceStatic() or Configuration::get(), it helps to open the class itself and look at the arguments.

What you look forWhere it is
The Product, Cart, Customer classesclasses/Product.php and neighbouring files
The Module classclasses/module/Module.php
The storefront product pagecontrollers/front/ProductController.php
The product page templatethemes/classic/templates/catalog/product.tpl
Symfony back office pagessrc/PrestaShopBundle/Controller/Admin

Logs and cache

PathWhat is there
var/logsError logs
var/cache/devThe cache in debug mode
var/cache/prodThe cache in normal mode

If a page returns a 500 error and the screen is empty, the first thing to check is the last lines of the file in var/logs.

The cache is cleared with a command run from the shop root:

php bin/console cache:clear

The command removes the Symfony cache of the current environment and prints a success message. The "Clear cache" button on the "Advanced Parameters → Performance" page also resets compiled Smarty templates.

The console

The bin/console file is the same Symfony console as in ordinary projects on that framework. The shop's own commands are listed like this:

php bin/console list prestashop

The list includes commands for installing modules; they are used in the next lessons.

Common mistake

The php bin/console command is run from the module folder and prints "Could not open input file". The bin/console path is relative to the shop root. Change to the root or give the full path: php /var/www/shop/bin/console.

Thanks for reading!

Donate to the site — we work hard for you.