I need to get the current product details in magento2 observer without using the registry.because magento latest version is deprecated this registry. I need the current product for reviews. when submit the form send the email

please help me.

3 Answers 3


This all depends on the event you are observering. Events can be fired from anywhere and usually have data assigned to the event itself - it may not always be the case that a product is defined in the registry when an event is fired.

If you are working with an event like catalog_product_save_after for example, you can access the product being saved like:

public function execute(\Magento\Framework\Event\Observer $observer): void
    $product = $observer->getEvent()->getData('product');
    if (!$product instanceof \Magento\Catalog\Api\Data\ProductInterface) {
    // We now have a valid $product, do whatever with it.
    $product->setData('foo', 'bar');


As you've mentioned in comments, it appears the event in question is review_save_after. The below code should work in your observer class:

/* @var $review \Magento\Review\Model\Review */
$review = $observer->getEvent()->getObject();
foreach ($review->getProductCollection() as $product) {
    // We now have access to each $product associated to the review.
    $product->setData('foo', 'bar');
  • Do you know the name of the event you are observing? It should be defined in your modules events.xml file. Feb 13 at 8:58
  • event name="review_save_after" Feb 13 at 10:15
  • I've updated my answer in relation to review_save_after event. Feb 13 at 11:16
  • Hi, it is set the data to product attribute. I need to get the current product details Feb 13 at 11:42

Yes, but the deprecated here is just a notice, and It stands in code for a long time, I'm using it day-by-day tasks and have no consequences, the registry still contains the data, so why not,


If you don't want to use Registry, you can try using $this->request->getParams().

You can get id in params,


For Product Id,

$this->request->getParam('product_id'); // Use this class in construct() \Magento\Framework\App\RequestInterface

In your Controller file

protected $request;

public function __construct(
        \Magento\Framework\App\RequestInterface $request
    ) {
        $this->request = $request;

public function execute()

To get id in getParam() you need to pass it as hidden field in phtml file

In your phtml file,

<input type="hidden" name="product_id" value="<?php echo $product_id ?>"> 

In Observer & Plugin File:- It depends on which event you want to observe and same goes for the plugin. If you're passing as hidden field and calling a observer on that particular event, you can get id as i mentioned above.

Your Answer

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

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