简体   繁体   English

magento 2.4.1 的单个产品详细信息页面上没有显示带有简单消息的定制模块?

[英]Custom built module with simple message is not displaying on single product detail page in magento 2.4.1?

So I've created one module to display "hello world" message on single product page like below:所以我创建了一个模块来在单个产品页面上显示“hello world”消息,如下所示:

However "Hello world" message is not displaying on product page.但是“Hello world”消息未显示在产品页面上。

My Custom Module look like below:我的自定义模块如下所示:

registration.php file look like below: registration.php 文件如下所示:

<?php 

\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE, //type
'Paymentblock_Ext', //componentName
__DIR__ //path
);

?>

module.xml file look like below: module.xml 文件如下所示:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Paymentblock_Ext" setup_version="1.0.0">
</module>
</config>

catalog_product_view.xml file look like below: catalog_product_view.xml 文件如下所示:

<?xml version="1.0"?>
<page layout="1column" 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="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
    </referenceContainer>
</body>

custom_ptype.phtml file look like below: custom_ptype.phtml 文件如下所示:

<h3>Hello World</h3>

PaymentMethod.php file look like below: PaymentMethod.php 文件如下所示:

<?php 

namespace Paymentblock\Ext\Block;

use Magento\Framework\View\Element\Template;

class PaymentMethod extends Template {  

}
?>

I've applied below command to see the module effects on product page:我已经应用了以下命令来查看产品页面上的模块效果:

php magento setup:di:compile

My module is in the list of enabled module as I can see here by applying below command:我的模块在启用的模块列表中,我可以通过应用以下命令在此处看到:

 php bin/magento module:status 

However, I am still not able to see the "Hello World" message on single product page.但是,我仍然无法在单个产品页面上看到“Hello World”消息。

can anyone please point me out what I am doing wrong here????谁能指出我在这里做错了什么????

Run setup upgrade to set up the module: php bin/magento setup:upgrade运行 setup upgrade 设置模块:php bin/magento setup:upgrade

Theme layout update file '/var/www/html/app/code/Paymentblock/Ext/view/frontend/layout/catalog_product_view.xml' is not valid.主题布局更新文件“/var/www/html/app/code/Paymentblock/Ext/view/frontend/layout/catalog_product_view.xml”无效。 Premature end of data in tag page line 2 Line: 8标记页第 2 行中的数据过早结束第 8 行

<?xml version="1.0"?>
<page layout="1column" 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="Paymentblock\Ext\Block\PaymentMethod" name="custompaymentblock" template="Paymentblock_Ext::custom_ptype.phtml"/>
    </referenceContainer>
</body>
</page>

Add </page>添加</page>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM