Invoking functions from XML files
You can create all types of records from XML files, but sometimes it is difficult to generate data that includes some business logic. You might want to modify records when a user installs a dependent module in production. For example, let's say you want to create a module to display books online. The my_library
module already has an image-cover
field. Imagine that, in the new module, you implemented logic to reduce the size of the image and stored it in the new thumbnail field. Now, when the user installs this module, they might already have books and images. It is not possible to generate thumbnails from the <record>
tags in the XML file. In this case, you can invoke the model
method through the <function>
tag.
How to do it...
For this recipe, we will use the code from the previous recipe. As an example, we will increase the existing book price by $10 USD. Note that you might use another currency based on company configurations...