0

How to add Custom table next to product attribute in a product detail page

enter image description here

2
  • What u want to show in the table? Oct 15, 2019 at 8:13
  • @HafizArslan I need to show hard coded html tags
    – Dev Space
    Oct 15, 2019 at 17:47

1 Answer 1

0

Create a Block in Admin site (like: Identifier is 'table') add HTML tags what u want.

Create a file, name is table.phtml

app/design/frontend/vendor/Theme/Magento_Catalog/templates/product/view/table.phtml

<?php
echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('table')->toHtml();
?>

Then call the file in catalog_product_view.xml

app/design/frontend/vendor/Theme/Magento_Catalog/layout/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">
        <block class="Magento\Catalog\Block\Product\View" name="table"
             template="Magento_Catalog::product/view/table.phtml" >
        </block>
       <move element="table" destination="product.info.main" after="product.info.stock.sku"/>
</page>

After that running these commands:

sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento cache:clean
sudo php bin/magento cache:flush

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .