【问题标题】:Custom Attribute field not saving to DB during onepage checkout Magento 1.6?在单页结帐 Magento 1.6 期间,自定义属性字段未保存到数据库?
【发布时间】:2011-12-29 09:47:12
【问题描述】:

有人可以帮忙吗?

我创建了一个带有 2 个自定义字段的新模块,所有似乎都可以正常工作,接受其中一个字段不会通过单页结帐过程保存到数据库吗?

我可以通过注册页面(register.phtml)输入数据,通过编辑账户页面(edit.phtml)编辑数据,这一切都保存到数据库中。

其中一个字段是从模型/实体中获取选项的选择字段,此字段保存正常,两个字段在 config.xml 文件中具有相同的条目。

我在 billing.phtml 中尝试过各种版本的输入

    <?php if(!$this->isCustomerLoggedIn()): ?>
    <li>    
    <label for="billing:childname" class="required"><em>*</em>
    <?php echo   $this->__('Childs Name') ?>
    </label>
    <div class="input-box">
    <input type="text" name="billing[childname]" id="billing:childname" 
    value="<?php echo $this->htmlEscape($this->getQuote()->getCustomerChildname()) ?>" 
    title="<?php echo $this->__('Childs Name') ?>" 
    class="input-text validate-text required-entry" />
    </div> 
    </li>

还有:value="htmlEscape($this->getCustomer()->getChildname()) ?>"

但我尝试的任何方法似乎都无法解决问题是什么??

非常感谢

【问题讨论】:

  • 您似乎正在尝试将该属性保存为帐单地址的一部分,但您将该属性称为属于客户对象。是地址属性还是客户属性?
  • @JoeConstant,抱歉延迟回复,我正在尝试将其保存为具有 entity_type_id = 1 的客户属性?谢谢

标签: mysql magento


【解决方案1】:

为了将您的 'childname' 属性保存在 DB 中,我们需要先将此值保存在 'sales_flat_quote' 表中。

请按照步骤获取要保存在数据库中的字段。

第 1 步: 通过运行以下查询在 sales_flat_quote 中添加新列。

ALTER TABLE  `sales_flat_quote` ADD  `customer_childname` INT NOT NULL

第2步:现在转到您的模块config.xml文件并将fieldsets代码下面的代码粘贴到全局块中,如果您没有自己的模块,则将其粘贴到任何其他模块中。

<global>
     //.....................
     <fieldsets>
       <checkout_onepage_quote>
         <customer_childname>
             <to_customer>childname</to_customer>
         </customer_childname>
       </checkout_onepage_quote>
        <customer_account>
            <childname>
                <to_quote>customer_childname</to_quote>
            </childname>
        </customer_account>     
      </fieldsets>
      //......................
</global>

现在检查一下:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多