Message-ID: <654916322.377618.1711635897556.JavaMail.root@confluence-doc2-production> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_377617_613563075.1711635897551" ------=_Part_377617_613563075.1711635897551 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Controllers within PrestaShop-

Controllers within PrestaShop-

Controllers within PrestaShop

=20 =20

In an MVC architecture, a Controller manages the synchronization events = between the View and the Model, and keeps them up to date. It receives all = the user events and triggers the actions to perform.
If an action needs = data to be changed, the Controller will "ask" the Model to change the data,= and in turn the Model will notify the View that the data has been changed,= so that the View can update itself.

All of PrestaShop's controllers actually override the Controller class through another inheriting class:

They can be found in the /classes/controller folder.

The FrontCo= ntroller class

Here are some of the class' properties:

Property Description
$template Template name for page content.
$css_files Array list of CSS files.
$js_files Array list of JavaScript files.
$errors Array of errors that have occurred.
$guestAllowed Whether a customer who has signed out can access= the page.
$initialized Whether the init() function has bee= n called.
$iso The ISO code of the currently selected language.=
$n The number of items per page.
$orderBy The field used to sort.
$orderWay Whether to sort is ascending or descending ("ASC= " or "DESC").
$p The current page number.
$ajax If the ajax parameter is detected in request, se= t this flag to true.

Execution order of the controller's functions

  1. __contruct(): Sets all the controller's member variables.<= /li>
  2. init(): Initializes the controller.
  3. setMedia() or setMobileMedia(): Adds all Java= Script and CSS specifics to the page so that they can be combined, compress= ed and cached (see PrestaShop's CCC tool, in the back office "Performance" = page, under the "Advanced preferences" menu).
  4. postProcess(): Handles ajaxProcess.
  5. initHeader(): Called before initContent().
  6. initContent(): Initializes the content.
  7. initFooter(): Called after initContent().
  8. display() or displayAjax(): Displays the cont= ent.

Exis= ting front office controllers

Here is the default controllers, and the theme files that use them .

Controller's filename Description
AddressController.php Used by address.php to edit a customer's address= .
AddressesController.php Used by addresses.php to get customer's addresse= s.
AttachmentController.php  
AuthController.php Used by authentication.php for customer login.
BestSalesController.php Used by best-sales.php to get best-sellers.
CartController.php Used by cart.php to manage the customer's cart.<= /td>
CategoryController Used by category.php to get product categories.<= /td>
ChangeCurrencyController.php  
CmsController.php Used by cms.php to get a CMS page.
CompareController.php Used by products-comparison.php to compare produ= cts.
ContactController.php Used by contact-form.php to send messages.
DiscountController.php Used by discount.php to get a customer's voucher= s.
GetFileController.php  
GuestTrackingController.php Used by guest-tracking.php to manage guest order= s.
HistoryController.php Used by history.php to get a customer's orders.<= /td>
IdentityController.php Used by identity.php for customer's personal inf= o.
IndexController.php Used by index.php to display the homepage.
ManufacturerController.php Used by manufacturer.php to get manufacturers.
MyAccountController.php Used by my-account.php to manage customer accoun= t.
NewProductsController.php Used by new-products.php to get new products.
OrderConfirmationController.php Used by order-confirmation.php for order confirm= ation.
OrderController.php Used by order.php to manage the five-step checko= ut.
OrderDetailController.php Used by order-detail.php to get a = customer order.
OrderFollowController.php Used by order-follow.php to get a = customer's returns.
OrderOpcController.php Used by order-opc.php to manage on= e-page checkout.
OrderReturnController.php Used by order-return.php to get a = merchandise return.
OrderSlipController.php Used by order-slip.php to get a cu= stomer's credit slips.
PageNotFoundController.php Used by 404.php to manage the "Pag= e not found" page.
ParentOrderController.php Manages shared order code.
PasswordController.php Used by password.php to reset a lo= st password.
PdfInvoiceController.php  
PdfOrderReturnController.php  
PdfOrderSlipController.php  
PricesDropController.php Used by prices-drop.php to get dis= counted products.
ProductController.php Used by product.php to get a produ= ct.
SearchController.php Used by search.php to get search r= esults.
SitemapController.php Used by sitemap.php to get the sit= emap.
StatisticsController.php  
StoresController.php Used by stores.php to get store in= formation.
SupplierController.php Used by supplier.php to get suppli= ers.

Overriding a = controller

Thanks to object inheritance, you can change a controller's behaviors, o= r add new ones.

Keep overrides for your own shop

Overrides in PrestaShop are exclusive. This means that if your module ov= errides one of PrestaShop's behaviors, another module will not be able to u= se that behavior properly, or override it in an predictable way.

Therefore, overrides should only be used for your own local modu= les, when you have a specific need that cannot be applied with it.=

It is not recommended to use an override in a module that you in= tend to distribute (for instance through the PrestaShop Addons mar= ketplace), and they are forbidden in partner modules.

PrestaShop's controllers are all stored in the /controllers= folder, and use the "Core" suffix.

For instance, when working with the Category controller:

In order to override a controller, you must first create a new class wit= hout the "Core" suffix, and place its file in the /override/controlle= rs folder.

For instance, when overriding the Category controller:

------=_Part_377617_613563075.1711635897551--