0

I made a custom module and I'm trying to save data into the module table so I wrote this code :

$model = Mage::getModel("modulepackage/name");
$model->setPostCode("XXXXX");
...
$model->setCity();
$model->save();

Everything is working perfectly in some file of my website but as soon as I place this code in my payment module (the module is supposed to track the credit card failed) it doesn't work anymore (no error thrown by Magento) but the data is not in the table. Do you have any idea ?

Thanks a lot !

2
  • might be issue of transaction rollback while payment fail Commented Apr 20, 2016 at 5:01
  • write your data in some file or session and catch them by some event observer this will be easy way i think Commented Apr 20, 2016 at 5:03

2 Answers 2

1

Inside the payment module, you will be inside a transaction. For this reason, your module save MAY be rolled back if the order doesn't go through. It sounds like this is what's happening, because that's a common reason why your data wouldn't save.

Some options:

  1. Use a queue, and place the operation onto the queue for out-of-process handling. If you haven't worked with queues before, this might not be the easiest option.

  2. Place the data into a singleton, or even the session, and then use a later event (like controller_action_postdispatch) to actually trigger writing it to the database - outside the transaction.

-1

Finally, I achieved it by insert the value in customer session and save it when the order is placed (listen event checkout_submit_all_after)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.