0

I'm trying to have a custom credit card payment attribute save to two different tables but I'm not sure how to do this.

The normal credit card information saves to two different tables.

  • sales_flat_quote_payment
  • sales_flat_order_payment

I created the new attribute and it should be saved to both tables. The column with the correct value has been set on both tables but it only saves to one "sales_flat_quote_payment" right when the customer places the order.

How can I make it so it saves the data to both tables?

I found this reference but I'm not sure how to implemente it to make it work with a credit card attribute value.

http://www.magentocommerce.com/boards/viewthread/19344/P0/

Can anyone confirm if this would work?

    <sales_copy_order_payment>
        <cc_bankname>
        <to_order>*</to_order>
        </cc_bankname>
    </sales_copy_order_payment>
BlueSun3k1
  • 757
  • 5
  • 21
  • 39

1 Answers1

2

Did you configure Magento to convert the new attribute from quote to order? If you check the config.xml from the Mage_Sales module and search for sales_convert_quote_payment. You see something as follows:

       <sales_convert_quote_payment>
            <method><to_order_payment>*</to_order_payment></method>
            <additional_data><to_order_payment>*</to_order_payment></additional_data>
            <additional_information><to_order_payment>*</to_order_payment></additional_information>
            <po_number><to_order_payment>*</to_order_payment></po_number>
            <cc_type><to_order_payment>*</to_order_payment></cc_type>
            <cc_number_enc><to_order_payment>*</to_order_payment></cc_number_enc>
            <cc_last4><to_order_payment>*</to_order_payment></cc_last4>
            <cc_owner><to_order_payment>*</to_order_payment></cc_owner>
            <cc_exp_month><to_order_payment>*</to_order_payment></cc_exp_month>
            <cc_exp_year><to_order_payment>*</to_order_payment></cc_exp_year>

            <cc_number><to_order_payment>*</to_order_payment></cc_number>
            <cc_cid><to_order_payment>*</to_order_payment></cc_cid>

            <cc_ss_issue><to_order_payment>*</to_order_payment></cc_ss_issue>
            <cc_ss_start_month><to_order_payment>*</to_order_payment></cc_ss_start_month>
            <cc_ss_start_year><to_order_payment>*</to_order_payment></cc_ss_start_year>
        </sales_convert_quote_payment>

Magento uses these fieldsets to transport data from entity to entity. In this case from the quote_payment to the order_payment.

Since all config XML is merged into one big heap of XML, you can add additional nodes from your own modules config.xml. Something like:

<global>
    <fieldsets>
        <sales_convert_quote_payment>
            <your_attribute><to_order_payment>*</to_order_payment></your_attribute>
        </sales_convert_quote_payment>
    </fieldsets>
</global>

Hope this helps you get underway.

Tim Hofman
  • 1,068
  • 7
  • 10
  • Thank you. I had previously overriden the mage/sales module but I have no idea why the config file that was located on the sales module was not the correct one. After looking at yours and your refernce, I copied the config.xml file again and edited the necessary fields. Unfortunately, I'll have to wait until the morning to confirm if it worked or not. I appreciate your help, I'll give more feedback in the morning. – BlueSun3k1 Aug 14 '12 at 22:12
  • Alright, I tested it by adding the attribute to the config.xml file and it didn't work. I made sure it was documented properly but the value is not copied over to the sales_flat_order_payment table. – BlueSun3k1 Aug 15 '12 at 19:58