使用CustomerThreadCore类在联系表Prestashop 1.7中添加其他字段

时间:2019-07-02 19:27:06

标签: php prestashop prestashop-1.7

在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();

但是我得到:发送消息时出错。

0 个答案:

没有答案