0

I've followed some suggestions to have some data copied over from one table to another table on the DB but it's not working.

Based on the response I received on this questions: Magento: How to save data to order_payment and quote_payment

I tried to do the following on the Mage/Sales/etc/Config.xml file

<sales_convert_order_payment>
            <cc_bankname>
                <to_quote_payment>cc_bankname</to_quote_payment>
            </cc_bankname>
</sales_convert_order_payment>

and this

<sales_convert_quote_payment>
            <cc_bankname>
                <to_order_payment>cc_bankname</to_order_payment>
            </cc_bankname>
</sales_convert_quote_payment>

but the bank name is only saved on the sales_flat_quote_payment table and not on the sales_flat_order_payment table which is the one I need to have this new data displayed on the order invoice and on the admin back-end under order/view.

If I manually input the data on the DB (the bank name that is) I'm able to display this information where it's needed but I cannot keep track of every transaction to manually input the data upon order completion since customers get to see their order details once it has been sumbited and they would not be able to view the new data until I have done so myself.

does anyone know why the data is not being carried over to the sales_fat_order_payment table?

I'm having the same issue with a new mobile number attribute I created but I believe if I can solve this one, then I should be able to handle all other similar issues.

BlueSun3k1
  • 757
  • 5
  • 21
  • 39
  • Attributes have their own table (I believe it's eav_attribute)... Are your attribute values being saved there?? – Zak Aug 16 '12 at 20:49
  • Yes, my new custom attributes are set on the eav_attribute table just like the other attributes of the same nature. by this I mean cc_owner (which comes by default with the magento install for the credit card owner name) and my custom attribute which is cc_bankname are both listed. Now the new data by the customers input when they pay with a credit card should be saved to sales_flat_quote_payment and sales_flat_order_payment but as I mentioned before, my custom attribute cc_bankname is only saving the bank name to sales_flat_quote_payment and not like cc_owner which is saved to both tables. – BlueSun3k1 Aug 16 '12 at 21:28
  • Have you already tried `*`, that is, using `*` instead of `cc_name` as node values? – Jürgen Thelen Aug 17 '12 at 00:30
  • @JürgenThelen yes I have tried it with the * and with the value itself as on the sample. I get the same results either way. I even tried editing the core/mage/sales/etc/config.xml to see if it was my local/mage file that was not being picked up my Magento but it still doesn't work. – BlueSun3k1 Aug 17 '12 at 13:59
  • I'd check whether `Mage_Sales_Model_Convert_Quote::paymentToOrderPayment()` will really be called. If so, turn on your debugger and single trace to find the problem. If the method is not called, check your payment method code why it's not calling the convert method. – Jürgen Thelen Aug 17 '12 at 14:35
  • Ok, I got it to work but not the way I wanted. This is what I did. 1. I manually deleted the var/cache data because flushing wasn't doing the trick. 2. I backed up and edited the core/mage/sales/etc/config.xml again and removed mine from local/mage/sales/etc/config.xml. This time it worked after manually deleting the var/cache unlike the first time I tried to use the core file. Now I don't know why magento is not picking up mine from the local/mage/sales/etc/ folder but it picks up everything else from my local folders. Now to figure out why magento isn't picking this particular file. – BlueSun3k1 Aug 17 '12 at 16:08
  • But I'm happy because it's all coming together. I can see my custom attributes on the back-end as well as on the invoices, on the front-end customer/orders and everywhere I wanted them to show. It worked very well for other custom attributes I had created. @JürgenThelen do you have any idea why magento isn't recognizing the local/mage/sales/etc/config.xml file? thanks again for your help. – BlueSun3k1 Aug 17 '12 at 16:10

1 Answers1

0

That technique (naming it using same name with Mage) won't work for config.xml. How it works? You need to read this article written by Alanstorm http://alanstorm.com/magento_config_declared_modules_tutorial

You need to create your own module by defining it in app/etc/modules (of course you should name it other than Mage).

eg: app/etc/modules/Test_Sales.xml

content:

<?xml version="1.0"?>
<config>
    <modules>
        <Test_Sales>
            <active>true</active>
            <codePool>local</codePool>
        </Test_Sales>
    </modules>
</config>

app/code/local/Test/Sales/etc/config.xml -> define your new config in here

In older version of magento, sales order stored in eav type. In higher version, it has been flatten. Look at the name: sales_flat_quote_payment, sales_flat_order_payment

Magento always keep their data backward compatible, that's why it has attribute name cc_owner in eav_attribute.

In your case, you don't need to create new value in eav_attribute (you just need to add column cc_bankname in sales_flat_quote_payment and sales_flat_order_payment which I'm pretty sure you have already created).

As you have said before, the problem why it is not saved to sales_flat_order_payment is because of cache issue (Magento cache the config.xml so you need to refresh it System > Cache Management > Configuration)

ivantedja
  • 2,553
  • 1
  • 22
  • 22