Magento payment : additional_information or payment attribute?

只谈情不闲聊 提交于 2019-12-21 14:32:13

问题


I'm wondering which is the better way to add some information to a payment in magento (1.4.1.1).

Let's say I want to add an information called "payment_duedate" which would be the date the customer has to pay his invoice.

Actually, there is a field in the sales_flat_order_payment called "additional_information" which contain serialized data set by the method setAdditionalInformation($arg1,$arg2); available in the 'sales/payment' model. So I could save my date by :

$payment->setAdditionalInformation('payment_duedate',$myDate);
$payment->save();

But one could also choose to add a payment attribute, which would have as effect to create a new column called 'payment_duedate' in the 'sales_flat_order_payment' and then save my date by doing :

$payment->setPaymentDuedate($myDate);
$payment->save();

The main differences are :

  • with the "additional_information method", datas are serialized, and so, not queryable easily.
  • with the "setPaymentDuedate() method", datas are queryable and a new field is created in the table

So, in your opinion, which of the two ways is the best ?

Thanks, Hugues.


回答1:


The setAdditionalInformation() is most useful for read-only attributes, such as a message to the user, like "Transaction Bank: MyBank".

The custom setPaymentDuedate() is useful for processing afters, like checking a payment status where Duedate > MMDDYY.




回答2:


I find the question to be subjective. And given that the second way isn't much more effort (see my experiences) it's hard to choose either one.



来源:https://stackoverflow.com/questions/4939916/magento-payment-additional-information-or-payment-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!