prestashop和helperlist活跃

时间:2018-01-26 13:21:26

标签: php prestashop

我正在尝试使用Helperlist在prestashop 1.6上添加目录/产品中的新列。

该列类似于“有效”列,它是一个简单的开关按钮,可将选项设置为true或false。

我编辑了控制器AdminProduct以添加字段,该字段显示字段列表的正确值(true或false),但该按钮不起作用(它不会切换为true为false),如活动按钮做。

活动按钮代码:

        $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
    );

我的代码:

        $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
    );

我查看了prestashop上的helperlist文档,但文档非常简单,这是我第一次使用HelperList,任何帮助都会很好。

我知道问题来自这一行:'active' => 'AllShopActive' 但我不知道如何解决它。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

最简单的方法是使用ajax实现它。要做到这一点,你需要添加' ajax' =>符合您的定义:

$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
);

然后将方法添加到控制器。像

这样的东西
public function ajaxProcessAllShopActiveProduct()
{
    your code here
}