I have a relatively straightforward module in Magento 2 for adding some extra functionality to the addto area on the product view page.
I wanted to append my own custom block after the product.info.addto block via a layout file, like so:
app/code/VENDOR/MODULE/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>
 <referenceBlock name="product.info.options.wrapper.bottom">
 <block
 class="VENDOR\MODULE\Block\Product"
 name="product.info.anyname"
 template="VENDOR_MODULE::test.phtml"
 after="product.info.addtocart" />
 </referenceBlock>
 </body>
</page>
with my template test.phtml file being a simple echo for now:
app/code/VENDOR/MODULE/view/frontend/templates/test.phtml
<?php echo 'LA TREY: '; ?>
after enabling module, and running the di:upgrade, compile and cache clear php bin/magento commands, I go to my catalog product view page and no change. My "La Trey" isn't there.
So I thought I could win by copying the layout/catalog_product/view.xml file to the theme's Magento_Catalog folder - but again, after running the commands - nothing.
How do I get my block to show after the addto container on the catalog product view page?
1 Answer 1
Update your XML file content with below code.
app/code/VENDOR/MODULE/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">
 <referenceBlock name="product.info.options.wrapper.bottom">
 <block
 class="VENDOR\MODULE\Block\Product"
 name="product.info.anyname"
 template="VENDOR_MODULE::test.phtml"
 after="product.info.addtocart" />
 </referenceBlock>
 </referenceContainer>
 </body>
</page>
After updating this please run below command once..
php bin/magento cache:flush
Output
Hope this will work!
- 
 Did you updated above content in your XML file ?Kishan Savaliya– Kishan Savaliya2020年09月21日 11:24:01 +00:00Commented Sep 21, 2020 at 11:24
- 
 Clear Magento cache once and tryKishan Savaliya– Kishan Savaliya2020年09月21日 11:24:56 +00:00Commented Sep 21, 2020 at 11:24
- 
 Also please check your module is enabled or not? If you've added above files in your module then please verify it once.Kishan Savaliya– Kishan Savaliya2020年09月21日 11:26:30 +00:00Commented Sep 21, 2020 at 11:26
- 
 Let us continue this discussion in chat.Kishan Savaliya– Kishan Savaliya2020年09月21日 11:27:49 +00:00Commented Sep 21, 2020 at 11:27
- 
 Seems fixing that block class issue didn't resolve it - you able to .zip up your plugin and send it over? I'll see if it works - if it doesn't, might be a problem with the themetreyBake– treyBake2020年09月21日 14:17:00 +00:00Commented Sep 21, 2020 at 14:17