Tictacbluw
Tictacbluw

Reputation: 31

prestashop and helperlist active

I'm trying to add à new column in catalog/product on prestashop 1.6 with Helperlist.

The column is similar to the "active" column, it's à simple switch button that turn the option to true or false.

I edited the controller AdminProduct to add the field, the field display the correct value (true or false) of the field list, but the button is not working (it's doesn't switch to true of false) like the active button do.

The active button code :

        $this->fields_list['active'] = array(
        'title' => $this->l('Status'),
        'active' => 'status',
        'filter_key' => $alias.'!active',
        'align' => 'text-center',
        'type' => 'bool',
        'class' => 'fixed-width-sm',
        'orderby' => false
    );

my code :

        $this->fields_list['AllShopActive'] = array(
        'title' => $this->l('All Shop'),
        'active' => 'AllShopActive',
        'filter_key' => 'a!AllShopActive',
        'align' => 'text-center',
        'type' => 'bool',
        'class' => 'fixed-width-sm',
        'orderby' => false
    );

I've looked in the helperlist doc on prestashop, but the documentation is very light and it's the first time I use HelperList, any help would be nice.

I know the problem come from this line : 'active' => 'AllShopActive' but I don't know how to solve it.

Thank you for your help.

Upvotes: 1

Views: 1223

Answers (1)

Alexander Grosul
Alexander Grosul

Reputation: 1814

The simplest way is to implement it with ajax. To do it you need to add 'ajax' => true to your definition:

$this->fields_list['AllShopActive'] = array(
    'title' => $this->l('All Shop'),
    'active' => 'AllShopActive',
    'filter_key' => 'a!AllShopActive',
    'align' => 'text-center',
    'type' => 'bool',
    'class' => 'fixed-width-sm',
    'orderby' => false,
    'ajax' => true
);

and than add the method to controller. Something like

public function ajaxProcessAllShopActiveProduct()
{
    your code here
}

Upvotes: 1

Related Questions