I would like add some static text to product views on product-info-main and should be multi language compatible how would I do that? As I understand I can inject static-block content but somehow is not working for me.
I added the following to my custom themes Maganeto_Catalog -> catalog_product_view.xml
<block class="Magento\Cms\Block\Block" name="custom.text">
<arguments>
<argument name="static_text" xsi:type="string">custom</argument>
</arguments>
</block>
and created in backed a static block with id static_text
but do not show up.
Best Answer
Magento 2 layout mechanism may load and process all the active layouts having the same name. So, in your case, if you want to add more content to product view, you can create the layouts having the same name with the product core layouts. For example, we create a module with the following folder structure:
In
catalog_product_view.xml
:We added three blocks. The first block will call a static block with id
hello-world
. The second block is the core block Magento which will render ourhello
templates. The last one is our custom block to showhello world
:The same logic for bundle and configurable layout. The most important thing is that we need to reference to a container node of catalog product layout.
There is another way that we will override the layout in our theme. For example, create
catalog_product_view.xml
under:<Vendor Theme>/<Theme>/Magento_Catalog/layout/catalog_product_view.xml
. And then, follow the same logic above to add our block content.