我正在开发一个custome Prestashop模块,经过几周的努力,我自己解决了大部分小问题。但是,我无法传递此错误消息:删除对象时发生了错误。avanto_keys (不能加载对象)
我的模块名是:avantokey
表列表的管理控制器是:AdminAvantokeyLogController
当我单击行操作按钮上的DELETE时,会弹出错误消息。知道为什么不能加载对象吗?
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;
}}
发布于 2017-06-18 18:29:35
我自己突然在另一个预铺舱找到了答案。这就是要使表行可删除的内容:在__constructor方法中添加这一行:
$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),
),
);
}发布于 2017-06-18 18:04:22
这张桌子有ObjectModel吗?
您需要在构造函数中指定它。
$this->className = 'myobjectmodel';https://stackoverflow.com/questions/44617823
复制相似问题