0

Is there a way to show all meta keywords for a product on its product detail page. something looks like below? enter image description here

I'm currently able to display the meta-keyword attribute values under the email icon( I added the following code at the end of the mailto.phtml).

<div class="tags">
    <hr />
        <b><?php echo $_product->getData('meta_keyword'); ?></b>
</div>

However, I want to display them like the image above ( in individual box) and move them underneath product title. enter image description here

2
  • what you have tried. How you have managed Meta Keywork – Amit Bera May 28 '20 at 6:59
  • i'm currently able to display the meta keywords underneath the email icon ( i added it at the end of the mailto.phtml). my Meta Keywords are store in the product attributes called 'meta_keyword'. thanks – Mage Explorer May 28 '20 at 17:38
1

You can reach this by creating catalog_product_view.xml layout in your custom module and add your block into product.info.main container like:

<?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="Magento\Catalog\Block\Product\View" name="meta_keywords" template="Test_Module::meta_keywords.phtml" before="-" />
        </referenceContainer>
    </body>
</page>

meta_keywords.phtml template:

<?php /** @var \Magento\Catalog\Block\Product\View $block */ ?>

<?= $block->escapeHtml($block->getProduct()->getData('meta_keywords')) ?>
1
  • thank you, it get me into the right direction. – Mage Explorer May 29 '20 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.