How to solve ‘Error: Undefined class constant’ after upgrading to Magento 2.4? [FREE SOLUTION]
Important: We’ve tested all our plugins for compatibility with Magento 2.4.0 and guarantee their smooth work with the latest version. But we also know that you may come across the ‘undefined class constant’ error caused by 3rd-party extensions. Being customer-centric, we developed a solution that will help you avert this problem. Below, you’ll find the mini-mod, addressing the issue and instructions on how to fix the error.
When upgrading your Magento to the latest 2.4.0 version, you may get an error on product or category pages:
Error: Undefined class constant 'XML_PATH_HEADER_TRANSLATE_TITLE' in app/code/Magento/Theme/Block/Html/Title.php:104
What triggers the error?
This error occurs if you use a third-party plugin with the Magento\Theme\Block\Html\Title class. After upgrading to Magento 2.4, the plugins that use features of this class will trigger the error.
And the reason is that this constant is defined as private and uses the static keyword. Thus, the system looks for the class instance but has no access to private variables of child classes.
How to fix the issue?
Magento 2 plans to fix this issue in the future release. But to help those who have no time for waiting, we developed our functional plugin. You need only to install it as you do with any third-party plugins before or after the upgrade to M 2.4.
What Amasty extensions can trigger the error if not updated to the latest version?
Here are some of our plugins that may trigger the error if not updated to their latest versions:
- Improved Layered Navigation (update to v. 2.14.4+)
- Shop by Brand (update to v. 2.13.1+)
- Google Rich Snippets (update to v. 1.4.8+)
- Meta Tags Templates (update to v. 1.2.2+)
Please, if you use these plugins, make sure you have installed the latest version to avoid this issue.