Php 如何在magento 2的可配置产品页面上添加自定义phtml文件
我正在创建一个自定义模块,我想在可配置产品页面的属性上方包含一个自定义phtml文件 请看一下我创建的模块文件,以及我在谷歌搜索后做了些什么-Php 如何在magento 2的可配置产品页面上添加自定义phtml文件,php,module,magento2,Php,Module,Magento2,我正在创建一个自定义模块,我想在可配置产品页面的属性上方包含一个自定义phtml文件 请看一下我创建的模块文件,以及我在谷歌搜索后做了些什么- etc/di.xml 我是通过这种方式实现的 view/Fronted/layout/catalog_product_view_type_configurable.xml 查看/templates/extra.phtml 将文件创建为 app/code/Vendor/Module/view/frontend/layout/catalog_p
- etc/di.xml
我是通过这种方式实现的 view/Fronted/layout/catalog_product_view_type_configurable.xml
查看/templates/extra.phtml
将文件创建为
app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml
文件:catalog\u product\u view.xml
PHTML文件中的
app/code/Vendor/Module/view/frontend/templates/product/view/cusrom.phtml
来自custom.phtml文件的hii
<?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>
<referenceBlock name="product.info.main">
<block after="product.info.price" class="Test\Mymodule\Block\Posts" name="extra" template="Test_Mymodule::extra.phtml" />
</referenceBlock>
</body>
<?php echo "<p>Extra Block</p>";
<?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" after="product.info.price"
as="custom"
template="Vendor_Module::product/view/custom.phtml"/>
</referenceContainer>
</body>
</page>
<div class='custom-box'>
<span class="custom">
hii from custom.phtml file
</span>
</div>