1

I am having trouble moving the short description on the product page. I tried with the move command within the layout file without any luck. I can move any new created block where I want but I can't modify theme declared layout blocks.

Location of my layout xml file

Vendor/Module/view/frontend/layout/catalog_product_view.xml

Layout file code

<?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>

        <!--This works as created above-->
        <move element="product.seller.list" destination="product.info.main" after="product.info.review"/> 

        <!--This does not work-->
        <move element="product.info.overview" destination="product.info.main" after="-"/>

    </body>
</page>

If I modify the theme layout file the move works. Any help will be great

0
0

product.info.overview is generally the last element of the product.info.main component. When you use after="-" you're making if the last element of the product.info.main component. I would try using before="-" so that it becomes the first element in that component or so you can at least see it move. Then you can specify where you want it based on the M2 dev docs for layout updates (https://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-instructions.html#fedg_layout_xml-instruc_ex_mv).

Also, if you're not seeing changes you may need to clear your layout cache or recompile php bin/magento cache:flush layout or php bin/magento setup:di:compile.

8
  • That is correct, normally it is at the bottom however the theme we are using they moved it to the top and I would like to move it to the bottom.I tried the above and it is not working. I can move my element however not the product.info.overview – master Mar 19 '19 at 11:33
  • I can however move the product.info.overview when I extend the theme file however I would like to do this from my module – master Mar 19 '19 at 11:35
  • Gotcha, that makes more sense. I believe that you’ll need to create a theme to go with your module and activate that theme. Because your other theme is active is not going to look at any of the layout files in your module. – mlunt Mar 19 '19 at 11:50
  • So you are saying there is no way to move an element from the module? just to make sure I understand – master Mar 19 '19 at 13:52
  • If you want to override as opposed to extend the path to the file needs to be different. It should be setup like this <theme_dir>/<Namespace_Module>/layout/override/theme/<Parent_Vendor>/<parent_theme>/catalog_product_view.xml. Generally, the approach is to extend, but in your case you can override the base xml with this approach and not have to create a theme to override the parent theme. More details on overriding a layout file here: devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/… – mlunt Mar 19 '19 at 14:01

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.