Listview Prestashop Backoffice controller-删除对象时出错(无法加载对象)

Listview Prestashop Backoffice controller-删除对象时出错(无法加载对象),listview,controller,prestashop,Listview,Controller,Prestashop,我正在开发一个custome Prestashop模块,经过几周的努力,我自己解决了大部分小问题。但是,我无法传递此错误消息:删除对象时出错。avanto_键(无法加载对象) 我的模块名是:avantokey 表列表的管理员控制器是:AdminAvantokeyLogController 当我单击行操作按钮上的删除时,会弹出一条错误消息。知道它为什么不能加载对象吗 class AdminAvantokeyLogController extends ModuleAdminControlle

我正在开发一个custome Prestashop模块,经过几周的努力,我自己解决了大部分小问题。但是,我无法传递此错误消息:删除对象时出错。avanto_键(无法加载对象)

我的模块名是:avantokey

表列表的管理员控制器是:AdminAvantokeyLogController

当我单击行操作按钮上的删除时,会弹出一条错误消息。知道它为什么不能加载对象吗

    class AdminAvantokeyLogController extends ModuleAdminController
{
    public function __construct()
    {

        $this->bootstrap = true;
        $this->module = 'avantokey'; // valid module name
        $this->table = 'avanto_keys'; // DB table name where your object data stored
        $this->identifier = 'id_avanto_keys';
        $this->fields_list = $this->fieldList();
        $this->actions = array('view', 'edit', 'delete');
        $this->bulk_actions = array(
            'delete' => array(
                'text' => $this->l('Delete selected'),
                'icon' => 'icon-trash',
                'confirm' => $this->l('Delete selected object?')
            )
        );

    parent::__construct();
    }

    public function fieldList()
    {

        $fields_list = array(
            'id_avanto_keys' => array(
                'title' => $this->l('ID Key'),
                'width' => 140,
                'type' => 'text',
            ),
            'id_product' => array(
                'title' => $this->l('Product'),
                'width' => 140,
                'type' => 'text',
            ),
            'serial_key' => array(
                'title' => $this->l('Serial'),
                'width' => 140,
                'type' => 'text',
            ),
        );
        return  $fields_list;
    }

}

您有表的ObjectModel吗

您需要在构造函数中指定它

$this->className = 'myobjectmodel';

我自己突然在另一个预演模块中找到了答案。这就是使表行可删除的内容: 在_构造函数方法中添加此额外行:

$this->className = "AvantoKeyTest"; // The class name of my object
然后您必须创建一个新的对象类。因此,我创建了一个新文件:“modulename”/classes/test.php

在这个文件中,我使用了以下方法:

class AvantoKeyTest extends ObjectModel
{
    /** @var string Name */
    public $user;
    public $comment;
    public $active;
    public $id_leoblog_blog;
    public $date_add;
    public $email;
    public $id_shop;
    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'avanto_keys',
        'primary' => 'id_avanto_keys',
        'fields' => array(
            'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
            'serial_key' => array('type' => self::TYPE_STRING, 'required' => false),
        ),
    );
}

你好!不,我没有。。。因此,我必须在_构造方法中包含这行代码。那么,我还必须创建一个额外的自定义objectModel吗?要么这样做,要么编写自己的
processDelete()
方法来处理删除行的操作。如果有批量删除操作,还需要编写
processBulkDelete()
方法。谢谢。我也会检查这个答案是否有效。也许这比创建一个新类更容易。解决方案确实是在_构造函数中添加以下行:$this->className=“AvantoKeyTest”;然后,您必须在类的路径中要求_:在本例中为AvantoKeyTest.php,然后创建:public static$definition方法。