Published: November 3, 2018
Last updated:

Uncaught ArgumentCountError: Too few arguments to function Mage_Sales_Model_Order::getCreatedAtFormated(), 0 passed

The following fatal PHP error is triggered on attempt to place order or send order confirmation email after upgrade to PHP 7.2 on Magento or OpenMage LTS stores:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Mage_Sales_Model_Order::getCreatedAtFormated(), 0 passed in lib/Varien/Filter/Template.php on line 301 and exactly 1 expected in app/code/core/Mage/Sales/Model/Order.php:2083

Cause

There is a call to getCreatedAtFormated() function in somewhere in the order confirmation email templates and it is passed without any arguments, i.e. like the following:
{{var invoice.getCreatedAtFormated()}}

Solution

To correct the error this call should be set in order confirmation email template with a defined format, like
{{var invoice.getCreatedAtFormated('short')}}
Alternatively, the function definition can be changed with override in local code:
--- app/code/core/Mage/Sales/Model/Order.php
+++ app/code/local/Mage/Sales/Model/Order.php
@@ -2080,7 +2080,7 @@
      * @param   string $format date format type (short|medium|long|full)
      * @return  string
      */
-    public function getCreatedAtFormated($format)
+    public function getCreatedAtFormated($format = 'short')


If you have any difficulties with solving this problem or got a similar one, please let us know in comments below, so we can find the solution together.

Posted in: Fatal errors

48 votes, 4.98 avg. rating (98% score)