From 97e200d20ce887cc7c68da57a4083a9cd8ea267f Mon Sep 17 00:00:00 2001 From: David Hiendl Date: Sun, 25 Jun 2023 19:25:31 +0200 Subject: [PATCH] Fixed eav_config_entity throwing error message on removed entity model (#3338) * fix eav_config_entity throwing error message on removed entity model * fix phpcs * fix exception message capitalization * fix log message capitalization --------- Co-authored-by: Fabrizio Balliano --- app/code/core/Mage/Eav/Model/Config.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/code/core/Mage/Eav/Model/Config.php b/app/code/core/Mage/Eav/Model/Config.php index 363cfd090d4..619c411aef6 100644 --- a/app/code/core/Mage/Eav/Model/Config.php +++ b/app/code/core/Mage/Eav/Model/Config.php @@ -186,8 +186,23 @@ protected function _loadEntityTypes() $this->_entityTypes = []; $this->_entityTypeByCode = []; $entityTypeCollection = Mage::getResourceModel('eav/entity_type_collection'); + /** @var Mage_Eav_Model_Entity_Type $entityType */ foreach ($entityTypeCollection as $entityType) { + // Ensure eav entity type model class is defined, otherwise skip processing it. + // This check prevents leftover eav_entity_type entries from disabled/removed modules creating errors and + // is necessary because the entire EAV model is now loaded eagerly for performance optimization. + $entityModelClass = $entityType['entity_model']; + $fqEntityModelClass = Mage::getConfig()->getModelClassName($entityModelClass); + if (!class_exists($fqEntityModelClass)) { + if (Mage::getIsDeveloperMode()) { + throw new Exception('Failed loading of eav entity type because it does not exist: ' . $entityModelClass); + } else { + Mage::log('Skipped loading of eav entity type because it does not exist: ' . $entityModelClass); + } + continue; + } + $this->_entityTypes[$entityType->getId()] = $entityType; $this->_entityTypeByCode[$entityType->getEntityTypeCode()] = $entityType; }