In Magento2, if we want the current category detail then we can retrieve it from Registry as below:

$currentCategory = $this->_registry->registry('current_category');

For Getting current product detail, then we can retrieve it from Registry as below:

$currentProduct = $this->_registry->registry('product');


$currentProduct = $this->_registry->registry('current_product');

So which one we should use or which one that Magento recommends for getting Current Product? why?


1 Answer 1


Take a look:


    // Register current data and dispatch final events
    $this->_coreRegistry->register('current_product', $product);
    $this->_coreRegistry->register('product', $product);

As we can see, Magento registers two variables. That why we can get by current_product and product variables. Seem that Magento wants to give us "more ways" to get the current product data in block, event,... via Registry.

See more:


    $this->_coreRegistry->register('category', $category);
    $this->_coreRegistry->register('current_category', $category);
  • Hello @Khoa, Thanks alot for your quick response. I am agreed in the case of getting current Product. But for getting current category specially on Frontend, we should only use: $currentCategory = $this->_registry->registry('current_category'); Jul 3, 2017 at 9:14
  • Yes, in category case I showed, it belongs to Admin area. Jul 3, 2017 at 9:15

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.