We want to determine whether a product is in Category ID 2 or not. In Mage1 we were able to get all configured Categories when being in the $\_product collection. In Magento2 it seems that there is no possibility to check what categories the product is configured to.

Is there a workaround for this? I've found a tutorial that says I need to inject something in the Block, but this does not work. See code below.

```
<?php
namespace ASDF\CurrentCat\Block;
class CurrentCat extends \Magento\Framework\View\Element\Template
{
        protected $_registry;

 public function __construct(
 \Magento\Backend\Block\Template\Context $context, 
 \Magento\Framework\Registry $registry,
 array $data = []
 )
 { 
 $this->_registry = $registry;
    parent::__construct($context, $data);
 }

 public function _prepareLayout() {
    return parent::_prepareLayout();
 }

 public function getCurrentCategory() { 
     return $this->_registry->registry('current_category');
    }

 public function getCurrentProduct() {
     return $this->_registry->registry('current_product');
    } 
}
?>

```

Especially the second function `(getcurrentProduct())` doesn't work.