I am trying to get the registry but its always returning null and i dont know why
class Extension extends \Magento\Framework\View\Element\Template {
protected $_urlBuilder;
protected $_storeManager;
protected $productRepository;
protected $_coreRegistry;
public function __contruct(
\Magento\Framework\UrlInterface $urlBuilder,
\Magento\Framework\Registry $registry,
\Magento\Store\Model\StoreManagerInterface $storeManager
){
$this->_urlBuilder = $urlBuilder;
$this->_storeManager=$storeManager;
$this->_coreRegistry = $registry;
}
const ICON_EXTENSION = '.gif';
const URL_ICON = 'images/productextension/';
public function getProduct()
{
return $this->_coreRegistry->registry('current_product');
}
Why is my registry null?