在CustomerThread.php文件中,我添加了我想使用的额外字段。
class CustomerThreadCore extends ObjectModel
{
public $id;
public $id_shop;
public $id_lang;
public $id_contact;
public $id_customer;
public $id_order;
public $id_product;
public $status;
public $email;
public $token;
public $date_add;
public $date_upd;
public $size_number; //this is my extra variable
在同一类下,我声明了新字段的类型
'size_number' => array(
'type' => self::TYPE_INT
),
在contactform.php文件中,我获取了该字段的值,并尝试将其传递给add()方法。
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int)$customer->id;
}
$ct->id_shop = (int)$this->context->shop->id;
$ct->id_order = $id_order;
if ($id_product = (int)Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int)$id_contact;
$ct->id_lang = (int)$this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->size_number = $size_number; //extra field it already has the value i need e.g. 42
$ct->add();
但是我得到:发送消息时出错。