1

i have about 100 catgory in admin, is there way to change layout of all catgory to 1column

i can do it from backend,but doing one by one will take too much time, is there way to do it quickly

enter image description here

i tried to do it from layout file but it is not working, below is my code of xml file , still is see products as 1 column-left

Magento_Catalog/layout/catalog_category_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */ 
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="div.sidebar.additional">
            <block class="Magento\Cms\Block\Block" name="banner_left" after="recentproductslider">
                <arguments>
                    <argument name="block_id" xsi:type="string">banner_left</argument>
                </arguments>
           </block>
         </referenceContainer>

        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Template" name="breadcrumbscategory" template="Magento_Theme::html/breadcrumbscategory.phtml" before="-"/>
            <block class="Magento\Framework\View\Element\Template" name="custom.text" template="Magento_Theme::html/custom-list-page.phtml" after="breadcrumbscategory"/>
        </referenceContainer>   
        <referenceBlock name="catalog.leftnav" remove="true" />
          <move element="category.view.container" destination="page.top" before="-"/>
         <!-- <move element="breadcrumbs" destination="category.view.container" before="page.main.title"/> -->
         <move element="page.main.title" destination="content" before="-"/>
         <referenceContainer name="page.main.title" remove="1"/>
 <referenceContainer name="breadcrumbs" remove="true" />
    </body>
</page>
  • yes you can do this from the layout file. – Dhiren Vasoya Mar 9 at 10:54
2

Maybe other modules rewrite that layout please check another module not conflict with it.

It is a bad habit to edit core files create the module and add the file to

app/code/Vendor/Modulename/view/frontend/layout/catalog_category_view.xml

add below code to file:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head></head>
    <body></body>
</page>

After this, please clear cache using below command :

php bin/magento cache:flush

Another Way

The xml file you want to override is

/vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml

So it should go in

app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml

Example override

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

</page>
| improve this answer | |
  • i am already following : Another Way , also no module in overriding that xml file, is there some different syntax as i am using magento 2.3 – user1799722 Mar 9 at 12:15
  • have you checked that there is varnish or anything is enabled because some time due to cache it does not reflect changes or please enable pathing and check that you are overriding the same file. even it does not work then let me know – Vikas kalal Mar 9 at 12:35
2

Create or open file app/design/frontend/[Theme-Package]/[theme]/Magento_Catalog/layout/catalog_category_view.xml

Change the following line:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

to:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
| improve this answer | |

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.