I am getting the below error while calling a function in my PHTML file
Fatal error: Uncaught Error: Call to a member function getTypeId() on null
public function getCurrentProductDealDetail()
{
$curPro = $this->coreRegistry->registry('current_product');
$productType = $curPro->getTypeId();
// echo $productType;
// die("bdvf");
$assDealDetails = [];
if ($productType == "configurable") {
$dataDeal = $this->getConfigAssociateProDeals(true);
} elseif ($productType == "grouped") {
$dataDeal = $this->getGroupAssociateProDeals(true);
} else {
$dataDeal = $this->helperData->getProductDealDetail($curPro);
if ($dataDeal) {
$dataDeal['entity_id'] = $curPro->getId();
}
}
return $dataDeal;
}
issue while calling the block here
<div class="deal-timer">
<?php
blockObj= $block->getLayout()->createBlock('V\M\Block\ViewProduct');
$dealDetail = $blockObj->getCurrentProductDealDetail();
$product = $blockObj->getCurrentProduct();
?>
</div>