2

Anybody have idea how to add/update "Custom Layout Update" field of category or product in magento version 2.3.4

According to magento standard document,"You can no longer specify an entity-specific layout update with text but instead must create a physical file that contains the layout updates and select it for use."

But there is no option to select physical file on categories or product edit level.

After upgrade version from 2.3.3 to 2.3.4, which categories have "Custom Layout Update" exist now those are with drop down and "Use existing" selected but which does not have custom layout update those are with "No update" on drop down.

so really confused that how we could add new or update existing?

Please help!

4

As of Magento 2.3.4, merchants can select layout updates to be applied to specific Category/Product/CMS Page pages on the frontend. These layout updates are made by creating layout XML files following specific naming conventions.

For Categories:

catalog_category_view_selectable_<Category ID>_<Layout Update Name>.xml

where:

  • Category ID is desired category ID
  • Layout Update Name is what is shown as the option for Custom layout update field of Design section on Category Edit page.

For Products:

catalog_product_view_selectable_<Product SKU>_<Layout Update Name>.xml

where:

  • Product SKU is the desired product’s SKU encoded as a URI. example: “My Product SKU” -> “My%20Product%20SKU”
  • Layout Update Name is what is shown as the option for Custom layout update field of Design section on Product Edit page.

For CMS Pages:

cms_page_view_selectable_<CMS Page Identifier>_<Layout Update Name>.xml

where:

  • CMS Page Identifier is the desired page’s URL Key with “/” symbols replaced with “_”
  • Layout Update Name is what is shown as the option for Custom layout update field of Design section on CMS Page Edit page

These files must be placed in the appropriate folders for layout XML files. They will be available as Custom Layout Update options for Merchants after flushing the cache.

This is a link to the DevDocs: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/xml-manage.html#create-cms-pageproductcategory-specific-layouts

| improve this answer | |
  • 1
    thats so weird so pages that have existing layout xml still have them but you have to go in the DB to change them! – Pierre-Verthume Larivière Feb 13 at 22:12
  • Thanks for the answer but how to add custom layout for home page. After adding the custom layout the layout only working with baseurl/home – Sushant Vishwas Feb 24 at 14:32
  • Is there any chance to create a common layout for all the cms page? – Ramya Apr 23 at 13:28
  • Anyone have idea how it's wrong here? magento.stackexchange.com/q/310447/60624 – Silver Apr 26 at 8:25
1

Create a custom layout file for category:

app/design/frontend/<Vendorname>/<themename>/Magento_Catalog/layout

catalog_category_view_selectable_<Category ID>_<Layout Update Name>.xml

Also check and save theme setting as Global: Admin > Content > Design > Configuration https://prnt.sc/r89ico

| improve this answer | |
1

In version 2.3.4 to add classes to the body tag for example, valid for pages::

<script type="text/javascript">
require([
    'jquery'       
], function (jQuery) {
    (function ($) {
        $("body").addClass('yourclass');
    })(jQuery);
});
</script>
| improve this answer | |
1

Any sort of idea why this has been done? I think is pretty bad to not be able to change Layout XML from the admin area anymore. It just makes it not very flexible. And it means that for any change on layout XML it will require a new deployment and a new file to be created. On a big website we could end up with loads of new XML files having to be created manually. Also, sometimes ID's on local environments are not the same as the ID's in staging or production environment. SO ...I am seeing this new update XML way quite useless.

| improve this answer | |
  • The function was removed from Magento to remove the opportunity for Remote Code Execution. – Bram Hammer Apr 17 at 7:15
1

I am struggling like @Bram Hammer. I placed the code below into app/design/frontend/Smartwave/porto_child/Magento_Catalog/layout/catalog_category_view_selectable_115_listview.xml and flushed cache. Porto Child is set to global under Content>Design>Configuration.

<body>
    <referenceContainer name="content">
        <referenceBlock name="product_list_toolbar">
            <action method="setData">
                <argument name="key" xsi:type="string">_current_grid_mode</argument>
                <argument name="value" xsi:type="string">list</argument>
            </action>
        </referenceBlock>
    </referenceContainer>
</body>

enter image description here

I still have no options under Catalog>Categories>ID: 115>Design>Custom Layout Update enter image description here

I'm trying to have category 115 default to list view instead of grid view. Hopefully somebody can see what I'm doing wrong.

| improve this answer | |
1

For anyone who has similar issue as @RonSayers (https://magento.stackexchange.com/a/311542/5983) - field without any options when using Porto theme (or any porto child themes).

Porto introduces a set of Smartwave modules, and while they are advertising as fully compatible with Magento 2.3 - they're not.

Smartwave_Megamenu is causing the issue as above. To fix, modify app/code/Smartwave/Megamenu/Model/Category/DataProvider.php and add 'custom_layout_update_file' in the design array.

It will show the options then.

| improve this answer | |
0

@sbodak

Following the Magento devdocs, and trying to create a custom layout like this for category :

catalog_category_view_selectable_3_categorycustom.xml

It's not working, not showing in the category design tab...

Any idea ?

| improve this answer | |
  • Did you refresh the cache? Where did you put this layout file? – sbodak Feb 15 at 20:33
  • right here : app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Catalog/layout/ – Clément CREUSAT Feb 17 at 7:07
  • select your theme as Global setting – manoj pal Feb 27 at 3:56
  • it worked ! thank you – Clément CREUSAT Feb 27 at 15:01
  • Same problem here. Theme is set as global (single store mode). File is placed in app/design/frontend/<your_vendor_name>/<your_theme_name>/Magento_Catalog/layout/ File name is: catalog_category_view_selectable_282_Reverseorder.xml Category id is: 282 What the hell am i doing wrong haha.. losing my mind over here. – Bram Hammer Apr 17 at 7:37

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.