Get Free Audit

How To Use The Class AdminCоntrоller In Prestashop

Jul 8, 2013

3502 Alex Simonchik

How To Use The Class AdminCоntrоller In Prestashop

Today we will learn how to use the class AdminCоntrоller and will create our own model. Our Admin class will use its data. It all will be based on our new module Frequently Asked Questions. Let’s first describe the tables which our new module will use.

There will be 3 of them:

  • Belvg_faq
  • Belvg_lang
  • Belvg_shop

The fields of the table belvg_fаq:

  • Id_belvg_faq
  • Position
  • Active

The fields of the table belvg_lаng allow you to use class data in multi language stores.

  • Id_belvg_faq
  • Id_lang
  • Title
  • Content

The fields of the table belvg_shоp are responsible for multi-store support

  • Id_belvg_faq
  • Id_shop

As soon as the database fields have been defined we can create a class-model. Let’s call this class FAQ:

So, the model has been created. With its help the data will be stored\edited in the database tables. In order to work with data, to initiate processes of creating new FAQ blocks, to sort and view the list of already existing blocks we need a class inherited from AdminCоntrоller. So we create a class with the name AdminFAQ:

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

The method renderForm draws this form:


The array $this- >fields_list, which is responsible for the data displayed in the controller’s grid, is initialized in the constructor:


Download Frequently Asked Questions module.

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


  1. Dear Jerry,

    unfortunately, we cannot provide a code review via the blog.
    Please contact our support department in case you need an individual consideration of the matter: [email protected]
    We’ll be happy to assist!

  2. Hello,
    I made a simple comment form, but I have a problem with the status: in the back office when I click on the comment the status updates without errors, even in the ps_comments table the status is updated, but when I update the page in the front office the disablited comment hides. Where am I doing wrong?
    This is the code
    class COMMENT extends ObjectModel
    public static function getComments ($ active = true, $ p = false, $ n = false)
        $ comments = Db :: getInstance (_PS_USE_SQL_SLAVE _) -> executeS (‘
    SELECT com. *, Cust.firstname, cust.lastname
    FROM '._DB_PREFIX _.' Comments com
    INNER JOIN '._DB_PREFIX _.' Customer cust ON (com.id_customer = cust.id_customer)
    ‘. ($ active?’ WHERE = 1 ‘:’ ‘).’
    ‘. ($ p?’ LIMIT ‘. (((int) $ p – 1) * (int) $ n).’, ‘. (int) $ n:’ ‘));

    if ($ comments === false)
    return false;
    $ counts = array ();
    if (count ($ counts))
    foreach ($ comments as $ key => $ comment)
    if (array_key_exists ((int) $ comment [‘id’], $ counts))
    $ comment [$ key] = $ counts [(int) $ comment [‘id’]];
    $ comment [$ key] = 0;
    Thank you

  3. Hi !
    In an admin module controller, is this possible to include $this->fields_list() in a bootsrap tabs grid ? Using something similar like we found in $this->fields_options = array(
    ‘appearance’ => array(
    ‘title’ => $this->l(‘Blabla’),
    ‘icon’ => ‘icon-html5’,
    ‘tabs’ => array(
    ‘tab1’ => $this->l(‘blabla tab1’),
    ‘tab2’ => $this->l(‘blabla tab2’),
    ‘tab3’ => $this->l(‘blabla tab3’),

  4. Hi,

    The admin side controller is not showing order by, search fields and Bulk dropdown. Its simple listing only, Can you please advise.

    Thank You

  5. Xavier,

    Yes, of course. That’s how most of the controllers work. For example, lets have a look at AdminCategoriesController.php witch works with _lang table as with the second table.

  6. Hi,

    I would like to do the same as you, but with 2 table.

    Is it possible ?

    I have a table for some elements, and another table with all names/descriptions etc


  7. Simon,

    It is pretty hard to say what exactly you are doing wrong without seeing the original version of your code. Perhaps, the problem is with the class of the model which interacts with your controller.

  8. Hi,

    I’ve created my AdminBlockQuoteController.php and BlockQuote.php (class model).

    But when i click to edit a record in the fields_list. It loads the renderform, but not the data in the fields? The fields are blank.

    Could you possibly suggest what I might be doing wrong?


  9. jQuery is already available in the backoffice right after Prestashop installation.

Post a new comment

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