2

I have an issue with the new Magento layout update xml feature. I added a custom layout update file to change a category. It shows up in the Magento backend, but when I select it, nothing changes on the frontend. Anyone that may know the solution?

I'm aware of the issue with porto theme & the new layout update feature, but that issue is already solved. It's just that the xml changes don't appear on the frontend.

The layout file content:

app/design/frontend/Smartwave/porto_child/Magento_Catalog/layout/catlog_category_view_selectable_9_TEST.xml

<?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">
    <update handle="catalog_category_view_selectable_9_TEST"/>
    <body>
        <css src="css/test.css" />
    </body>
</page> 

The category config:

enter image description here

5
  • You want to add CSS using custom layout update ? – Pawan Sep 28 '20 at 15:46
  • That's just for test purpose. CSS files are easy to check if it works. – MartinE Sep 29 '20 at 8:49
  • you need to use <head> tag instead of <body> for adding css – Pawan Sep 29 '20 at 10:03
  • You can also add <referenceBlock name="page.main.title" remove="true"/> in body tag and see if it removes page title. – Pawan Sep 29 '20 at 10:07
  • both dont work. <head> instead of <body> doesnt work. Also tried your suggestion with the page.main.title, but also doesnt work unfortunately – MartinE Sep 30 '20 at 12:32
0

Did you find a solution for this? I am using Porto with Magento 2.4.2 and can't get the Custom Layout Update to have any effect on the frontend either...

What do you mean by "I'm aware of the issue with Porto theme & the new layout update feature, but that issue is already solved."?

Are you referencing the backend Custom Layout Update drop down display issue? I tried the solution suggested here: How to add/update custom layout update on magento 2.3.4 and it seemed to fix that part of the issue, but I still can't get the Custom Layout Update to have any effect on the frontend.

Trying to add a category page specific css file just like you....and I am stuck!

Any info you can share would be greatly appreciated! Thank you!

1
  • Hi @MartinE, Thank you very much - I was just explaining the issue to the Porto developer... I will give pass this suggestion along to them. Thank you much appreciated! – Chris Mar 26 at 13:57
0

Eventually, we found a solution. The reason this doesn't work, is because of the Porto theme.

We edited 2 files:

app/code/Smartwave/Megamenu/Model/Category/DataProvider.php

Added 'custom_layout_update_file' to design block below 'custom_layout_update'

app/code/Smartwave/Porto/etc/di.xml

Removed <preference for="Magento\Catalog\Controller\Category\View" type="Smartwave\Porto\Controller\Category\View" />

Re-deployed everything after these changes, and it worked perfectly.

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.