Here is a simple module that displays static static html content on the product page.
You can try it.
It 100% works on my local Magento 2 test environment.
Base folder: app\code
Directory tree:
└── Test
└── Catalog
├── Block
│ └── Rewrite
│ └── Product
│ └── View.php
├── composer.json
├── etc
│ └── module.xml
├── registration.php
└── view
└── frontend
├── layout
│ └── catalog_product_view.xml
└── templates
└── test.phtml
File: Test/Catalog/composer.json
{
"name": "test/catalog",
"description": "Test module for Magento 2",
"type": "magento2-module",
"version": "1.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/module-catalog": "~100.0"
},
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Test\\Catalog\\": ""
}
}
}
File: Test/Catalog/registration.php
<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Test_Catalog', __DIR__);
File: Test/Catalog/etc/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="Test_Catalog" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
File: Test/Catalog/view/frontend/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">
<body>
<referenceContainer name="content">
<block class="Test\Catalog\Block\Rewrite\Product\View" name="product.seller.list" template="test.phtml" />
</referenceContainer>
</body>
</page>
File: Test/Catalog/Block/Rewrite/Product/View.php
<?php
namespace Test\Catalog\Block\Rewrite\Product;
class View extends \Magento\Catalog\Block\Product\View
{
}
File: Test/Catalog/view/frontend/templates/test.phtml
!!!!some static content!!!!
Best Answer
From what i understand you can't use
ifconfig
on move. In the classMagento\Framework\View\Layout\Reader\Block.php
there is a check for the attributeifconfig
:$configPath = (string)$currentElement->getAttribute('ifconfig');
source:
https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/View/Layout/Reader/Block.php
However on the move block is doesn't actually check for the
ifconfig
attribute:https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/View/Layout/Reader/Move.php#L49
In Theroy you shouldn't need the ifconfig on the move if there is already an ifconfig on the block as the block won't be rendered and thus not moved.
Hope that makes sense.