【问题标题】:Magento: modifying the newsletter moduleMagento:修改时事通讯模块
【发布时间】:2025-12-15 16:40:01
【问题描述】:

magento 的时事通讯表带有名字和姓氏字段,但在默认设置中只保存电子邮件地址。我想使用名字字段,但是在定位记录的保存位置时遇到了一些麻烦。

这就是我的表单现在的样子:

 <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
    <div class="block-content">
        <table>
            <tr>
                <td><label for="firstname"><?php echo $this->__('Name:') ?></label></td>
                <td>
                    <div class="input-box">
                        <input type="text" name="firstname" id="firstname" title="<?php echo $this->__('Name') ?>" class="input-text" />
                    </div>
                </td>
            </tr>
            <tr>
                <td> <label for="newsletter"><?php echo $this->__('Email:') ?></label></td>
                <td>
                    <div class="input-box">
                        <input type="text" name="email" id="newsletter" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
                    </div>
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <div class="actions">
                        <button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><?php echo $this->__('Sign Up') ?></button>

                    </div>
                </td>
            </tr>
        </table>

    </div>
</form>

有一个类似的post,但我认为它现在已经过时了,因为我似乎找不到 _prepareSave 函数。

有人可以在正确的方向上提供帮助吗?

谢谢, 比利

【问题讨论】:

    标签: php magento


    【解决方案1】:

    可以在here找到一个更简单的解决方案,将自定义字段添加到 Magento 时事通讯订阅者对象中

    【讨论】:

      【解决方案2】:

      新闻通讯和订阅者表至少在最新版本 Magento EE 1.9.1.1 中不包含名字和姓氏字段。

      如果你想在订阅者表中添加一个额外的字段,你应该更新Mage_Newsletter_Model_Subscriber类的subscribe方法(它只接收一个电子邮件地址,你应该传递额外的参数)和控制器@987654323 @, action newAction 以便它从 $_POST 数组中提取其他字段并用于创建时事通讯订阅(搜索指令$status = Mage::getModel('newsletter/subscriber')-&gt;subscribe($email))。

      【讨论】:

      • 是的,您是对的,时事通讯确实有名字和姓氏,但它们仅用于注册并检查订阅时事通讯的客户。欢呼
      • 您好,您能否将您的答案扩展到在哪里可以找到 1.9 的类和一些示例?谢谢。我刚刚开始 Magento 开发
      最近更新 更多