【问题标题】:Prestashop add customer methodPrestashop 添加客户方法
【发布时间】:2014-10-26 16:27:00
【问题描述】:

我在扩展 ModuleFrontController 的类的 init() 方法中有一段这样的代码,但它不起作用,我不知道为什么。我检查了 Customer 类中的定义,只需要名称、电子邮件和密码,但数据库中没有发生任何事情。 Prestashop 1.5.6.1

$customer = new Customer();
$customer->firstname = 'name';
$customer->lastname = 'lastname';
$customer->email = 'mail@mail.com';
$customer->passwd = md5(time());
$customer->is_guest = 1;

$customer->add();

编辑:这段代码在同一个类的 postProcess() 方法中工作,所以出了什么问题..?

【问题讨论】:

    标签: php prestashop


    【解决方案1】:

    如果您将代码放在 init() 方法下 - 您将覆盖默认的 init。

    尝试先调用父级 init,然后添加您的代码:

    public function init()
    { 
        parent::init(); 
        ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多