O'Reilly logo

PrestaShop Module Development by Fabien Serny

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Using Context and its Methods

In PrestaShop, the Context object is something close to (but unfortunately not as flexible as) a service container (or dependency injection container) that you can have in other frameworks. This container is filled with common objects (such as cookies, current language, and so on), and services (such as Smarty).

In this chapter, we will learn how to:

  • Use the l method and make your module multilingual
  • Use the addCSS and addJS methods to improve the ergonomy in the front office

Looking at the Context object

The Context objectis a directory containing a list of objects. It is available in controllers and modules, and you can access it this way:

$this->context;

If you are not in a controller or a module, you can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required