Magento 2 - php 7.2 - The each() function is deprecated in AbstractCollection.php
-
18-03-2021 - |
Question
I am getting below error in Magento 2.1 using PHP 7.2.
main.CRITICAL: Exception: Deprecated Functionality: The each() function is deprecated. This message will be suppressed on further calls in /vendor/magento/module-eav/Model/Entity/Collection/ on line 803 in
list($tableAlias, $tableName) = each($table);
Solution
As Answer Refereed by @RohanHapani
You Should use:
list($tableAlias, $tableName) = [key($table), current($table)];
Then Code is Like:
if (is_array($table)){
list($tableAlias, $tableName) = [key($table), current($table)];
} else {
$tableName = $table;
}
Hope this may help You!!
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange