I have created custom phtml file, but that file is calling to all the products magento2
Please find the below code:
<referenceContainer name="product.info.form.content" >
<block
class="Vendor\Module\Block\Product\View\RewardMesg"
name="reward_frontend_msg"
template="Vendor_Module::product/view/rewardMesg.phtml" before="product.info.addtocart"/>
</referenceContainer>
My block code is:
namespace Vendor\Module\Block\Product\View;
use Magento\Framework\View\Element\Template;
use Magento\Framework\Registry;
class RewardMesg extends Template
{
/**
* @var Registry
*/
protected $registry;
/**
* @var \Magento\Catalog\Model\Product
*/
protected $product;
/**
* ProductView constructor.
* @param Template\Context $context
* @param array $data
* @param Registry $registry
*/
public function __construct(
Template\Context $context,
array $data = [],
Registry $registry
)
{
$this->registry = $registry;
parent::__construct($context, $data);
}
/**
* @return \Magento\Catalog\Model\Product
*/
public function getProduct()
{
if (is_null($this->product)) {
$this->product = $this->registry->registry('product');
}
return $this->product;
}
}
Help me appriciate.
Thanks