0

Hi I used reference container on catalog_product_view.xml but it shows just on configurable products. I add another one without additional and just shows on simple products. Also used move command but still can't see in both simple and configurable product. What should I do? I am using Magento 2.1.8

        <referenceBlock name="product.info.addtocart">
            <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="Magento_Catalog::product/view/addto.phtml" before="-"/>
        </referenceBlock>
        <referenceBlock name="product.info.addtocart.additional">
            <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="Magento_Catalog::product/view/addto.phtml" before="-"/>
        </referenceBlock>
2

Finally solved by below instruction:

Add

   <referenceBlock name="product.info.addtocart">
       <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="Magento_Catalog::product/view/addto.phtml" before="-"/>
   </referenceBlock>

to "catalog_product_view_type_simple.xml"

and

   <referenceBlock name="product.info.addtocart.additional">
               <block class="Magento\Catalog\Block\Product\View" name="product.info.addto" as="addto" template="Magento_Catalog::product/view/addto.phtml" before="-"/>
   </referenceBlock>

to "catalog_product_view.xml"

0

I can confirm the block name product.info.addtocart.additional and product.info.addtocart work as expected for configurable products and simple products respectively.

Since you can't see the block yourself, you have likely some customisations, or custom theme that changes the way magento product layout works.

To debug this, my suggestion may be:

  • look at the log for possible errors

  • find in your app/code folder and app/design/frontend folder the word addto.phtml; This name is the template name and it should be showing you where in your system you have some customisations changing the behaviour of this template? of course find the word product.info.addtocart in these folders will be useful too

  • then more deeper, in the function \Magento\Framework\View\Layout::generateXml, add the line (temporarily) $xml->asXML();die(); and then view source will show you all the blocks in your page

--> to do this last step, if you are worry to change the core or find it geek to look at the layout from view source, you may either use Magento debbuging tool to show you all the blocks (although it will be limited for your case as your block does not appear) and then I find the plugin from Alan Storm quite useful in these cases..

  • Thanks for your answer, but unfortunately it didn't work for me – MGPM Dec 29 '18 at 6:36
  • ok, how about flushing the cache, sometimes easy tricks are the ones we can forget.. – Herve Tribouilloy Dec 29 '18 at 10:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.