Magento: Not able to save data on multiple tables on DB - magento

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.

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)

Related

Magento error in admin - Payment method does not exist

I had been using a custom payment module that I had built from scratch to accept payments from a particular gateway company. However, the company has recently uploaded a better magento extension that i have now uploaded.
However, since I also cleared the old files for clarity the order details page no longer opens generating an error that the payment method does not exist.
I am guessing that for each order, Magento would store the payment method in the database. If I can get hold of that attribute and change all old values to the new value id - this error would be taken care of.
I have looked in the sales_flat_order and many other tables but cannot figure out where this value is stored. Can anyone point the actual table and attribute.
This is stored in the method column of the sales_flat_quote_payment and sales_flat_order_payment tables.

Magento table rates and multiple stores?

I am trying to make my table rates work with my multi store setup. I have 2 stores (not only store views) for the same installation and I want table rates for that.
I tried with the built in table rates and I also tried with http://www.magentocommerce.com/magento-connect/webshopapps-matrixrate-1-multiple-table-rates-extension.html.
The problem is, this only seems to work for my first store, the second store always tells me that there is no shipping available in the OPC.
I checked the tables shipping_tablerate and shipping_matrixrate (this one comes from the extension) and both have the website_id column which is 1 (my first store) for me. I tried changing from 1 to 3 (thats the id of my other store), did not help.
This is the content for the extensions file:
Land,Region/Staat,Stadt,"Zip/Postal Code From","Zip/Postal Code To","Gewicht From","Gewicht To",Versandkosten,"Delivery Type"
DEU,*,,,,1.1000,2.0000,4.4000,Versand
DEU,*,,,,2.1000,5.0000,6.9900,Versand
DEU,*,,,,0.2000,1.0000,3.9500,Versand
DEU,*,,,,0.0000,0.1000,6.9900,Versand
How can I make this work for my second store as well?
Thanks!
you just need to import csv for all websites.
No changes in code.

Saving Extension Config Data Magento

I've been trying to figure out exactly how does magento save the config data for a module given in System.xml. reason?I would like to edit the data provided by the user before storing it in the database.
Any clues????
Take a look at Mage_Core_Model_Store::setConfig function (and getConfig for reading the value). You will probbably have to write an observer that will listen to store_save_before event.
Magento stores configuration data in core_config_data database table - path column is the hierarhical structure of XML elements in system.xml file and is the same as XPath used for reading the default value out of config.xml file and value column contains the value that was saved.
When accessing the data with for e.g. Mage::getStoreConfig( 'path', $storeId ); Magento first searches the table for path-value pair and if it doesn't find it it reads the default value from config.xml file.

Magento: How to save data to order_payment and quote_payment

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>
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.

Magento - Store Config only added to database after being saved

I have noticed that in Magento the core_config_data table is very small just after installation and it gradually gets populated over time ONLY when sections of the system config are saved. For example there are no values in the core_config_data table for the contacts settings - yet i can still do Mage::getStoreConfig('contacts/contacts/enabled') and get the correct value.
So, does this mean that magento is simply reading the config xml until a value is saved, and at which point it saves to the database and then the value is read from there?
If this is the case, then surely this is a bad design pattern, having these values stored in two places?
I think this post may help.
The Magento Config: Loading System Variables

Resources