Filtrare lista Prestashop 1.7

Salut,

Imi bat capul de cateva zile si nu am reusit sa gasesc nicio solutie. Am cautat atat de mult ca Google mi-a afisat recaptcha la rezultate.

Incerc sa fac pentru un modul o simpla lista care sa imi afiseze pe modelul prestashop toate datele din tabel. Dupa multe chinuri am reusit sa fac o listare, ordonare si paginare. Doar ca searchul nu functioneaza.

Arata cam asa

Problema intervine acum. Daca doresc sa caut ceva prin completarea campurilor de sus, nu se intampla absolut nimic. Am cautat exemple in module existente, m-am uitat in sursele de la prestashop si nu imi dau seama de ce nu merge.

Controller-ul meu arata asa:

<?php
class AdminHistory extends ModuleAdminController
{
    public function __construct()
    {
        $this->table = 'tabel_db';
        $this->show_toolbar = false;
        $this->identifier = 'id';
        $this->bootstrap = true;
        $this->list_simple_header = false;
        $this->display = 'list';
        $this->meta_title = 'Istoric';
        $this->deleted = false;
        $this->colorOnBackground = false;
        $this->bulk_actions = array();
        $this->actions = array();
        $this->context = Context::getContext();
        $this->_pagination = array(2, 50, 100, 300);

        $this->_defaultOrderBy = 'id';
        $this->_defaultOrderWay = 'DESC';

        parent::__construct();
    }

    public function renderList()
    {
        $this->fields_list = array(
            'id' => array(
                'title' => 'Id',
                'width' => 30,
                'type' => 'text',
                'havingFilter' => true
            ),
            'phone' => array(
                'title' => 'Telefon',
                'width' => 140,
                'type' => 'text',
                'havingFilter' => true
            ),
            'status' => array(
                'title' => 'Status',
                'width' => 30,
                'type' => 'text',
                'havingFilter' => true
            ),
            'message' => array(
                'title' => 'Mesaj',
                'width' => 50,
                'type' => 'text',
                'havingFilter' => true
            ),
            'details' => array(
                'title' => 'Detalii',
                'width' => 140,
                'type' => 'text',
                'havingFilter' => true
            ),
            'content' => array(
                'title' => 'Continut',
                'width' => 140,
                'type' => 'text',
                'havingFilter' => true
            ),
            'type' => array(
                'title' => 'Tip',
                'width' => 50,
                'type' => 'text',
                'havingFilter' => true
            ),
            'sent_on' => array(
                'title' => 'Data',
                'width' => 140,
                'type' => 'text',
                'havingFilter' => true
            ),
        );
        $lists = parent::renderList();
        parent::initToolbar();
        return $lists;
    }

    public function initPageHeaderToolbar()
    {
        $this->page_header_toolbar_title = 'Istoric';
        parent::initPageHeaderToolbar();
    }
}

Daca cineva a mai lucrat cu asa ceva, va rog ajutati-ma cu un sfat. Multumesc.

Poveste clasica, postat problema, gasit raspuns imediat dupa.

Trebuia ca $this->fields_list sa il definesc in __construct() si nu in renderList().

3 Likes