What I wanted to achieve:
I would like to add some codes to the OnepageController (ie checkout page) which checks the database for the number of orders thus far today, and then inform the current customer of expected delay if the number of orders exceeded a configurable limit.
What I thought should be done:
The indexAction function in OnepageController.php should be overloaded to make a database call, and perform some logic conditionals, and then set some flag somewhere, or trigger a function, so that the Onepage block or the onepage.phtml can retrieve the result and display the informational message.
However, I could not figure out how this is done. The call from OnepageController (or any controller) to trigger the loading of the page is almost magical (via loadlayout and renderlayout?). There is no call to any block, nor any call to any .phtml.
I tried $this->getLayout()->getBlock(’onepage’) but that didn’t work.
Can anyone show me a simple example of such a call?
What I did instead:
As I couldn’t figure out how to do the above, I put the database accessor and logics in the onepage block instead, and provide a accessor in the onepage block. The onepage.phtml can call the accessor function via $this->function()
This is horribly wrong as blocks shouldn’t access the database or hold the logics.