how to add custom phtml file in magento 2.3.1
-
15-04-2021 - |
题
how to add product.info referenceBlock add custom phtml in magento 2.3.1 but not added
app/design/frontend/{Theme}/{name}/Magento_Catalog/layout/catalog_product_view.xml
<referenceBlock name="product.info">
<block class="Magento\Catalog\Block\Product\View" name="product.items" template="Magento_Catalog::product/view/items.phtml"/>
</referenceBlock>
解决方案 2
app/design/frontend/{Theme}/{name}/Magento_Catalog/layout/catalog_product_view.xml
<move element="product.info" destination="product.info.bottom.part" before="-"/>
<referenceBlock name="product.info">
<block class="Magento\Catalog\Block\Product\View" as="product_info_items" name="product.info.items" template="Magento_Catalog::product/view/items.phtml"/>
</referenceBlock>
app/design/frontend/{Theme}/{name}/Magento_Catalog/templates/product/view/form.phtml
<?= $block->getChildHtml('product_info_items') ?>
其他提示
If You Have To Add Any Kind Of Extra In Formation In Your Product Detail Page Than You Can Used That Below Code Like That
app/design/frontend/Vendor_Name/luma_child/Magento_Catalog/templates/product/view/product-specification.phtml
Add That Below Type Of Code Here I Add The Description
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php
$_product = $block->getProduct();
$specification = $_product->getData('description');
?>
<div>
<h4>PRODUCT SPECIFICATIONS: </h4>
<span><?php echo $specification; ?></span>
</div>
<div>
<h4>USEFUL INFORMATION: </h4>
<span><?php echo $specification; ?></span>
</div>
Call this Phtml File In Your catalog_product_view.xml File As Per Your Requirement
app/design/frontend/Vrinsoft/luma_child/Magento_Catalog/layout/catalog_product_view.xml
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Product\View" name="product.info.specification" template="Magento_Catalog::product/view/product-specification.phtml"/>
</referenceContainer>
<move element="product.info.specification" destination="product.info.main" after="product.info.extrahint" />
Add this code befor body and And Here You See That