0

我有一个找不到正确答案的问题。在 Magento 中,我想将 DOB 添加到时事通讯订阅者中。通过遵循本教程,我成功地做到了:

http://www.iamrookie.com/blog/159/add-custo-field-in-newsletter-module-magento.html

所以现在我在我的数据库和 Magento 的后端看到了一个 DOB 行。如果我在数据库中设置一个日期(我没有使用注册表单进行测试),我会看到正确的值。

我唯一想做的就是检查客户是否在他的个人资料中设置了 DOB。如果是这样,我想用他的 DOB 覆盖数据库中的值。

这应该是可能的,因为您还可以在后端看到客户的名字和姓氏。

我相信我应该更改它的文件是subscriber.php。我已经尝试了不同的东西,但没有任何效果。

我想我应该在这里做点什么:

/**
     * Load subscriber info by customer
     *
     * @param Mage_Customer_Model_Customer $customer
     * @return Mage_Newsletter_Model_Subscriber
     */
    public function loadByCustomer(Mage_Customer_Model_Customer $customer)
    {
        $data = $this->getResource()->loadByCustomer($customer);
        $this->addData($data);
        if (!empty($data) && $customer->getId() && !$this->getCustomerId()) {
            $this->setCustomerId($customer->getId());

            $this->setSubscriberConfirmCode($this->randomSequence());
            if ($this->getStatus()==self::STATUS_NOT_ACTIVE) {
                $this->setStatus($customer->getIsSubscribed() ? self::STATUS_SUBSCRIBED : self::STATUS_UNSUBSCRIBED);
            }
            $this->save();
        }
        return $this;
    }

或者在这里:

/**
     * Retrieve Subscribers Full Name if it was set
     *
     * @return string|null
     */
    public function getSubscriberFullName()
    {
        $name = null;
        if ($this->hasCustomerFirstname() || $this->hasCustomerLastname()) {
            $name = $this->getCustomerFirstname() . ' ' . $this->getCustomerLastname();
        }
        return $name;
    }

但我真的不知道。如果有人知道如何完成这项工作,我真的很感激!

4

0 回答 0