1

I'm using Magento 2.1 and I just wanted to move a block in the product view layout, extending the existing layout.

My theme inherits from blank theme, and I have tried just to copy/paste what is done in magento-luma theme, and how it is explained in the official guide

(here and here)

So I just created an extending catalog_product_view.xml inside

app/design/frontend/Vendor_name/theme_name/Magento_Catalog/layout

with a similar content of what is done in luma-theme, like this

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.main.title" destination="product.info.main" before="-"/>
    </body>
</page>

but actually, nothing is moving.

I also tried overriding the layout, either the theme layout, as well as the module base layout, as mentioned in the official guide about overriding themes (here).

Cleared cache several times, regenerated static files, but nothing continues to happen.

What am I missing?

EDIT:

checking for erros in log files, in system.log I found this:

    [2017-08-30 13:21:48] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_411c931cf412fc3b1664f9d6f27c7e38e and handles default, catalog_product_view, catalog_product_view_id_1, catalog_product_view_sku_Primo%20prodotto, catalog_product_view_type_virtual: Please correct the XML data and try again.  [] []
[2017-08-30 13:21:48] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_40a98983867a1770682b48d9a0ad63441 and handles 1column: Please correct the XML data and try again.  [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'catalog.compare.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'sale.reorder.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'wishlist_sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'product.info.price' tries to reorder itself towards 'product.info.review', but their parents are different: 'product.info.main' and 'product.info.price' respectively. [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'product.price.final' tries to reorder itself towards 'product.info.sku', but their parents are different: 'product.info.price' and 'product.info.stock.sku' respectively. [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'product.info.social' tries to reorder itself towards 'product.info.overview', but their parents are different: 'product.info.extrahint' and 'product.info.main' respectively. [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'view.addto.wishlist' tries to reorder itself towards 'view.addto.requisition', but their parents are different: 'product.info.addto' and '' respectively. [] []
[2017-08-30 13:21:48] main.CRITICAL: Broken reference: the 'bml.right.logo' tries to reorder itself towards 'product.info.addtocart.paypal', but their parents are different: 'product.info.addtocart' and '' respectively. [] []
[2017-08-30 13:21:48] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_46f1b068ec7ccf4878f9284dd1137afd1 and handles catalog_product_prices: Please correct the XML data and try again.  [] []
[2017-08-30 13:21:57] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4c7dd4384a0ea945ae0d791fa12c5fba3 and handles review_product_listajax: Please correct the XML data and try again.  [] []
[2017-08-30 13:21:57] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4c7dd4384a0ea945ae0d791fa12c5fba3 and handles review_product_listajax: Please correct the XML data and try again.  [] []

but actually, updating the catalog_product_view.xml to this

<page layout="1column" 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.overview" remove="true" />
        </body>
    </page>

still does not reflect on the frontend, nor in the log files. It seems simply ignored.

I am in developer mode and disabled all cache files.

EDIT2:

comes out that the system.log errors are a not yet corrected Magento bug, and nothing important.

The other try I have done is to modify the catalog_product_view.xml in Magento/luma theme and it behaves exactly as expected.

Tried to extend another layout in my theme and no effect.

In the end I have created other two themes from scratch, one inheriting from blank and the other from luma, and the remove instruction works. But still no luck with move.

  • path should be Magento_Catalog.. is it typo? Because "C" should be capital – Abhishek Panchal Aug 29 '17 at 15:33
  • yes it is a typo. thx I correct. – sissy Aug 29 '17 at 15:37
  • Where are you trying to move it? My title is at top anyway. Setting this <move element="page.main.title" destination="product.info.main" before="product.info.media"/> moves it to bottom however so this may be worth checking to debug. – harri Aug 30 '17 at 7:41
  • if you compare the position of the main title (<div class="page-title-wrapper product">....</div> ) in blank theme, with its position in luma, you can see that in blank theme it is directly inside the <main id="maincontent">...</main>, whereas in luma, it is moved inside <div class="column main">...</div>, which is inside <main>..</main>. I just want to play around with layouts, I don't have a precise objective to achieve. – sissy Aug 30 '17 at 8:24
  • Yeah did you try the bit of code i pasted to see if it moved? I think you will need to change destination to move outside of the block on right however. e.g. <move element="page.main.title" destination="content" before="-"/> will movwe it outside of that block and to top of page.. – harri Aug 30 '17 at 9:55
2

The block is currently at the top of product.info.main so may not be moving due to this.

Try below to move to another container:

e.g

<?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>
    <move element="page.main.title" destination="content" before="-"/>
  </body>
</page>

Study vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml to see what containers exist and what they contain.

You can then set the destination to the container you wish. To order within the container you can change the before or after argument to the name of the block you want it to be before or after or before="-" for before all or after="-" for after all.

See below for a lot more on layouts:

http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/layouts/xml-instructions.html

  • thank you for the answer. I already tried different combinations of the move/remove instructions and studied all the sections concerning the layout manipulation. i created my theme and successfully extended the blank one with less and stuff like that. But i do not understand my problems with the layout. Dunno what are they concerned... oh, and i am using magento 2.1.7, not 2.0 – sissy Aug 30 '17 at 12:18
  • So nothing you change is reflecting on the frontend? Ok i changed the link they should be pretty much the same however – harri Aug 30 '17 at 12:24
  • yes no change on the xml layout is reflecting on the front. i have also tried to use the default.xml as a last chance, but nothing. only changing phtml templates and static styling files. there must be something before that i am missing,but have no clue on what. Ok for the link, it was just for the sake of clarity. – sissy Aug 30 '17 at 12:27
  • hmm i'm not sure you seem like your very much on the right lines. I run in developer mode for dev with no cache. Changing the layouts instantly reflect for me in that situation. In production i normally run setup:upgrade compile, deploy and then that works also. – harri Aug 30 '17 at 12:30
  • Have you checked for any errors in var/log? – harri Aug 30 '17 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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