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

Inserting a value to the new field that I created in Magento database

我的问题对于 magento 开发人员来说可能很蹩脚,但我是这个平台的新手。我在我的时事通讯订阅中添加了一个名为报价类型的新输入字段,因为我鼓励用户订阅以获得促销代码。

我添加了隐藏在静态页面的input类型

<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/controllers/SubscriberController.php 我添加了以下行

 $offer = (string) $this->getRequest()->getPost('couponName');
 $status = Mage::getModel('newsletter/subscriber')->subscribe($email,$offer);

在app/code/core/Mage/Newsletter/Model/Subscriber.php我添加了以下内容

 public function subscribe($email, $offer){

将 $offer 作为新参数插入到数据库中我的时事通讯 table 的报价字段中。 有人告诉我,Magento 会给我自动访问 getOffer 和 setOffer 的权限,所以我为相同的方法添加了以下内容

$this->setOffer($offer);

问题是我可以回显那个值,但是我不能将它插入到数据库中只有我可以插入电子邮件接下来是什么?

谢谢

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

类似于:

$quote->setCouponCode();

$引用->保存();