Get Free Audit

Category/Catalog page (Controller, Modules, Hooks) in Prestashop

May 6, 2013

2242 Alex Simonchik

Category/Catalog page (Controller, Modules, Hooks) in Prestashop

Controller (CategoryController)

/controllers/front/CategoryController.php

CаtegоryCоntrоller is responsible for generating the directory pages. It is inherited from the FrоntCоntrоller class. Let’s take a look at the methods that are called by this controller. But first let’s recollect the order in which the methods of the class Controller are called.

The methods of the CаtegоryCоntrоller class:

  • setMedia – Sets default medias for this controller
  • canonicalRedirection –  Automatically redirects to the canonical URL if needed (is called in FrontController::init())
  • init – Initializes category controller
  • initContent (see Controller Class RequestFlow) – The template, responsible for displaying the page of the categories category.tpl, is defined here.
  • assignScenes – Assigns scenes template vars
  • assignSubcategories – Assigns sub categories templates vars
  • assignProductList – Assigns list of products template vars. This method has a single hook in the whole controller “асtiоnPrоduсtListOverride”


 

Template

The category template category.tpl is one of the most complicated templates because it connects a great number of other templates:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

  • breadcrumb.tpl – adds the block breadcrumb to the page
  • errors.tpl – if there are any errors on the page they are displayed via this block
  • category-count.tpl – is responsible for showing the line with the number of goods, for example «There are %d products»
  • scenes.tpl – displays the image with the marked out goods
  • pagination.tpl – is responsible for navigating to other pages
  • product-sort.tpl – is responsible for outputting the fields for sorting
  • product-compare.tpl – displays the button for comparing goods
  • nbr-product-page.tpl – the form with the choice of the number goods on the page
  • product-list.tpl – the main template, which contains the marking-up to display goods
  • product-sort.tpl  –is called on the page for the second time
  • product-compare.tpl – is called on the page for the second time
  • nbr-product-page.tpl – is called on the page for the second time
  • pagination.tpl – is called on the page for the second tiome
Andrey_Dubina

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

Standard modules

The page with categories is running multiple modules registered in the hooks of the left and right-hand columns and others. We will take a closer look at all these modules in a separate chapter. This chapter will be devoted to one of these, the extension that uses the hook “асtiоnPrоduсtListOverride” – «Layered navigation block».

1

2

By default this module is disabled. «Layered navigation block» is very important for users because it allows finding the necessary product much faster and more easily. But this module is not very convenient for the layout designers and programmers because it does not separate the logic and template. This issue, however, will be most likely fixed in the future versions.

3

Magento 2 Development

Take your online store to the next level with BelVG Magento 2 Development

Visit the page
Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *