Let’s start with user case that happened to us when developing our new module. We had to add a filter by category into the AdminCоtrоller, the same way it is made on the page with a list of products. (more…)
In this article we continue exploring Prestashop modules. You’ll find out more about the Module class, the most demanded modules and conflicts between extensions.
1.1 The Module class
Almost all modules are inherited from the class Module. These are the hooks which are called in a class:
- Hook::exec(‘actionModuleInstallBefore’, array(‘object’ => $this)); //is called before installing a module
- Hook::exec(‘actionModuleInstallAfter’, array(‘object’ => $this)); //is called after installing a module
- Hook::exec(‘displayPayment’); //this hook is designed for payment modules.
1.2 The main modules
Let’s take a look at some of Prestаshоp modules. We will not describe them in details, since there are over 100 of them and with each new Prestashop version this number may change.
Bank Wire -the module which allows your customers to pay by bank transfer.
CMS Block – displays a block with articles. An administrator can create blocks himself and then select the location either in the left-hand or right-hand hooks.
This is one of the most important modules that can be considered as a hallmark of Prestаshоp. It uses the hooks Top and Header. The constant PS_BLOCK_CART_AJAX is responsible for its usage. The function of the class cart- >getPrоduсts( ); is responsible for getting products into the shopping cart.
This module is used to pay a courier. It uses the following hooks: payment, paymentReturn
This one uses the hooks: leftColumn, footer, header
The module which displays the block with a choice of currency.
This module is provided for free, but since the version 2.1.1 it is a paid option.
This module allows you to add content on your homepage.
This one adds a slider on your homepage.
This module displays a block with a language selection on the front-end.
This module outputs the block which allows users to quickly filter out products in a category.
This allows users to leave comments to products. A website administrator can set the product evaluation criteria, enable or disable comment moderation.
$categoryProducts = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. * / – the place in the module code, which gets products from a category.
Displays goods from the main category, to which a product is assigned, on a product page.
The module allows you to search for items in a catalog. In the default theme it is displayed at the top of the page. It can either search for pages using аjаx or show the so-called instant search results (read our article on how Prestashop search works here).
The block with a horizontal menu.
This module will help protect your unique products images from being copied. It adds a “watermark” with your store’s logo on all images.
The block with a wishlist. It is a useful module, which for some reason is disabled by default. In general, many modules are turned off by default after the installation.
1.3 Conflicts between modules
Conflicts between modules are not a rare thing. Our support team is constantly customizing our modules with modules of other companies as we frequently deal with the stores which already have certain methods rewritten. The most common issue is the inability to install a module, interrupted by the error message “The method Boo in the class Foo is already overriden”. This means that your system already has a method rewritten, which has been changed in our module too. Here we have described in details the function addOverride which returns this error.
Another common problem is that modules are not compatible with the standard module layered navigation block. Sometimes you need to re-initialize the modules that use fаnсybоx or other js-libraries.