I am having this issue with magento 2.4.6 custom module and php8.2

This code:

public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        \Magento\Framework\Registry $registry,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
    ) {
        $this->messageManager = $messageManager;
        $this->_storeManager = $storeManager;
        $this->_objectManager = $objectManager;
        $this->_coreRegistry = $registry;
        $this->_localeDate = $localeDate;

line with

$this->_coreRegistry = $registry;

Throw error:

Exception #0 (Exception): Deprecated Functionality: Creation of dynamic property \Helper\Data::$_coreRegistry is deprecated in app/code/MyFolder/Helper/Data.php on line 47

I have no clue what to change and fix this

Any help please?


1 Answer 1


Deprecated Functionality: Creation of dynamic property \Helper\Data::$_coreRegistry is deprecated

You must declare this property ($_coreRegistry) in your class.
To do this, add the following code above the __construct method:

 * @var \Magento\Framework\Registry
private $_coreRegistry;

There is another solution is changing this property ($_coreRegistry) in your class to match the $argument in the __construct method, which is $registry. To do this, replace all text _coreRegistry with registry.

Here, I highly recommend using the second solution as it leverages the constructor property promotion (new feature) in PHP 8. To view a demonstration of this feature, you can watch the following video: https://www.youtube.com/watch?v=I960JDkmXY0

  • 1
    Thanks! It's work for me! Oct 18, 2023 at 12:34
  • 1
    @qɐʇǝɥɐW My pleasure.
    – Tu Van
    Oct 18, 2023 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.