Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向我在Magento数据库中创建的新字段插入值_Php_Mysql_Magento_Newsletter - Fatal编程技术网

Php 向我在Magento数据库中创建的新字段插入值

Php 向我在Magento数据库中创建的新字段插入值,php,mysql,magento,newsletter,Php,Mysql,Magento,Newsletter,对于magento开发人员来说,我的问题可能是站不住脚的,但我对这个平台非常陌生。我在我的时事通讯订阅中添加了一个新的输入字段,名为offer type,因为我鼓励用户订阅以获取促销代码 我添加了隐藏在静态页面中的输入类型 <input placeholder="email: example@example.com" class="email-offer-revealer" name="email" required="" autocapitalize="off" autocorrect=

对于magento开发人员来说,我的问题可能是站不住脚的,但我对这个平台非常陌生。我在我的时事通讯订阅中添加了一个新的输入字段,名为offer type,因为我鼓励用户订阅以获取促销代码

我添加了隐藏在静态页面中的输入类型

<input placeholder="email: example@example.com" class="email-offer-revealer" name="email" required="" autocapitalize="off" autocorrect="off" spellcheck="false" type="email">
<input name="couponName" value="first offer" type="hidden">
在app/code/core/Mage/Newsletter/Model/Subscriber.php中,我添加了以下内容

 public function subscribe($email, $offer){
$offer作为新参数插入DB中我的新闻稿表中的offer字段。 我被告知Magento将自动访问getOffer和setOffer,因此我为相同的方法添加了以下内容

$this->setOffer($offer);
问题是我可以回显该值,但我不能将其插入数据库,只能插入电子邮件下一步是什么


谢谢

当您更新模型中的某些值时,您可以尝试调用save将新值放入数据库

比如:

$quote->setCouponCode


$quote->save

您是否在时事通讯订阅表中添加了新的字段offer是的,我当然添加了一个名为offer的varchar字段,这就是为什么我在代码中添加了setOffer和getOffer,因为您不应该接触核心文件,你应该通过扩展重写它们,或者将它们复制到local/mage/…我会尝试一下,因为这是我还没有尝试过的唯一选项,谢谢你,不管怎样它是有效的!!谢谢你$this->save;$this->setOffer$offer之后;工作很有魅力
$this->setOffer($offer);