Custom Submission Functionality
Let's create observer function for WebForms that dumps submitted result into XML file.
We will be creating new extension called MageMe_WebFormsProcessResult.
#
File structure#
composer.jsonThis file holds information for composer script
#
registration.phpThis file registers module in the Magento system. The module is not visible without it.
#
etc/module.xmlThis file holds basic description of our module. We need to set the sequence so that the module is loaded after the main WebForms extension.
#
etc/events.xmlThis file registers our event handler function.
#
Observer/WebformsResultSaveObserver.phpHere we define our model of the event observer class. It has some basic members to work with stores, system messages and logging.
$destinationFolder - variable that sets folder where result is being stored. We will be creating files in pub/media/webforms/xml folder.
$filename - is complete path to the file. For example pub/media/webforms/xml/123.xml.
note
Make sure pub/media folder is writable.
After the module is ready, please run following console commands:
Thats it! Feel free to modify this extension, experiment and add required post processing functionality to WebForms.
You can download sources here.