How to set Custom Layout Update XML in Magento 2.3.4

Hi Craig, hi guys,

I wonder if you could help.
I recently installed M2.3.4 and a 3rd party module.
All good the module works fine, however, I need to place code into the Layout Update XML field which in M2.3.4 was removed from the admin panel.

Can I please ask you to guide me on where should I create the file?
Thank you.

Pawel

"Removal of custom layout updates and the deprecation of layout updates to remove the opportunity for Remote Code Execution (RCE). The Custom Layout Update field on the CMS Page Edit, Category Edit, and Product Edit pages has now been converted to a selector.

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. The name of the file containing an update must follow the conventions described." - Magento

I’ll be honest, I don’t have an exact answer or any experience with updating the Custom Layouts using the new method. You’d have to refer to the Official Magento Documentation.

However, a brief skim of the documentation seems quite straightforward by adding layout XML files to your child theme. Would have been nice if they expanded on the examples a bit more though.

Create cms-page/product/category-specific layouts

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.

Educated Guess (Not tested)

  1. Having not tried this, I suspect (but not sure) that in your scenario it might be something like:

    catalog_category_view_selectable_2_AmastyFinder.xml
    
  2. And then I’d guess that you’d just copy/paste the contents of what you need it to be.

  3. And then finally I’d guess that you’d save the XML file in here (if you’re still using Porto):

    app/design/frontend/Smartwave/porto_child/Magento_Catalog/layout/
    
  4. Then clear the cache and cross your fingers that the option you created appears in the dropdown

No idea how you’d implement this across a bunch of Categories at once though, as you seem to need to specify a Category ID for each file?!?! Although, I guess you could apply it to a Parent Category and then set the Children to use the same layout? Purely guess work.

Please, let me know how you get on with this.