hi i want to know is it possible to show a custom meta tag here i have created an attribute and assigned to the seo group and i want this value to be visible under meta tag for the current product
default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<meta property="og:type" content="product" />
</head>
<body>
<referenceBlock name="head.additional">
<block class="Test\Meta\Block\Meta" name="custom_meta" template="Test_Meta::custom_meta.phtml"/>
</referenceBlock>
</body>
</page>
phtml file
<?php
$productCollection = $block->getProductCollection();
foreach ($productCollection as $product) {
print_r($product->getData());
echo "<br>";
$attribute = $_product->getResource()->getAttribute('miscellaneous_meta');
$attribute->getFrontend()->getValue($_product);
$attribute->getFrontendLabel();
}
block file
<?php
namespace Test\Meta\Block;
class Meta extends \Magento\Framework\View\Element\Template
{
protected $_productCollectionFactory;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
array $data = []
)
{
$this->_productCollectionFactory = $productCollectionFactory;
parent::__construct($context, $data);
}
public function getProductCollection()
{
$collection = $this->_productCollectionFactory->create();
$collection->addAttributeToSelect('*');
$collection->addAttributeToFilter('miscellaneous_meta');
return $collection;
}
}
?>
but this is not working!!