* Registry model. Used to manage values in registry
 * Registry usage as a shared service introduces temporal, hard to detect coupling into system.
 * It's usage should be avoid. Use service classes or data providers instead.
 * @api
 * @deprecated
 * @since 100.0.2


enter image description here

Who can show me a demo that use service classes or data providers instead.


2 Answers 2


Here you can find the way how to avoid usage of Registry - https://www.atwix.com/development/alternatives-for-deprecated-registry-class-magento-2-3/


The correct way of getting the current product on PDP page without using registry class is to use Catalog Helper class.

public function __construct(    
    \Magento\Catalog\Helper\Data $catalogHelper
) {
    $this->catalogHelper = $catalogHelper;

public function run() {

By looking at the implementation you will see that it is still using registry class under the hood, but that is okay because when core class will be refactored to not use registry class, your code will not break and you should still get your product. This is the whole purpose of the helper class, essentially you are shifting responsibility to the framework from your own implementation, which is the best you can do in this scenario.

enter image description here

  • 1
    It is not ok because this helper is not marked with @api tag. The @api tag guarantees that public interface (methods) won't be changed in the future non-major updates.
    – MTP
    Commented Nov 11, 2022 at 5:57
  • @MTP you may be right but there is no alternative to that at the moment, this is still better than using method that has been marked deprecated.
    – Timik
    Commented Nov 22, 2022 at 4:11

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.