Magento 1 – PHP Fatal error: getAllOptions() on PHP 7.2
Ever faced an error that says,
PHP Fatal error: Declaration of Mage_Customer_Model_Customer_Attribute_Source_Website::getAllOptions() must be compatible with Mage_Eav_Model_Entity_Attribute_Source_Table::getAllOptions($withEmpty = true, $defaultValues = false) in /app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php on line 34
It looks something like this in Magento 1 store:
The above PHP error usually occurs in Magento 1 store when upgrading to PHP 7.2. When this error occurs, you may not be able to open any customers in the admin dashboard.
Also, you may not be able to export customers from the backend when this php error occurs.
This post discusses the programmatic solution for this Magento 1 – PHP Fatal error: getAllOptions() on PHP7 .2.
Implement the steps shown below to resolve the error.
Solution for Magento 1 – PHP Fatal error: getAllOptions() on PHP 7.2:
app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php
app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Source/Country.php
app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Group.php
app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php
app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Store.php
Copy these files to the local folder
So the paths will be created as follows:
app/code/local/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php
app/code/local/Mage/Customer/Model/Entity/Address/Attribute/Source/Country.php
app/code/local/Mage/Customer/Model/Customer/Attribute/Source/Group.php
app/code/local/Mage/Customer/Model/Customer/Attribute/Source/Website.php
app/code/local/Mage/Customer/Model/Customer/Attribute/Source/Store.php
In these five files, you’ll find a line that states:
1 |
public function getAllOptions() |
Change the above line to
1 |
public function getAllOptions($withEmpty = true, $defaultValues = false) |
That’s it.
Any doubts about the above solution can be mentioned in the Comments section below.
I’d be happy to help you asap.
Also, make sure to migrate to the latest Magento 2 store in order to avail the performance and security features offered by Magento 2.4.1
You can skip the tedious task and simply opt for Meetanshi’s Magento 2 Migration Service that will offer professional help in migrating your store to the latest Magento 2 version under the guidance of certified Magento developers!
Do share the post with Magento 1 developers via social media.
Thank you.
Jignesh Parmar
An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.
Prev
A Definitive Guide on Magento 2 Security [2024]
How to Show Subtotal Besides Cart Icon in Magento 2
Next