If you want create custom block on product detail page, then following can be helpful.
Add layout in your custom module.
/app/code/Custom/Module/view/frontend/layout/catalog_product_view.xml
Add following lines in catalog_product_view.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.main">
<block class="Custom\Module\Block\Product\Sizechart" name="size.chart" after="-" template="sizechart.phtml" />
</referenceContainer>
</body>
</page>
Then create block in Block folder like,
/app/code/Custom/Module/Block/Product/Sizechart.php
Add following in Sizechart.php
<?php
namespace Custom\Module\Block\Product;
class Sizechart extends \Magento\Framework\View\Element\Template
{
protected $_coreRegistry;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Registry $registry
){
$this->_coreRegistry = $registry;
parent::__construct($context);
}
public function getProduct()
{
return $this->_coreRegistry->registry('current_product');
}
}
Then create phtml file in view/templates path like,
/app/code/Custom/Module/view/frontend/templates/sizechart.phtml
Add your custom code there,
.......
<?php $_product = $block->getProduct(); ?>
.......