0

On 3 of my products I wanted to change the look & feel along with the layout

As an example, I want to move the product title so I have created a new child theme like below

/app/design/frontend/[Vendor]/[Child_Theme_Name]/Magento_Catalog/layout/catalog_product_view.xml

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.main.title" destination="main" before="-"/>
    </body>
</page>

/app/design/frontend/[Vendor]/[Child_Theme_Name]/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/[Vendor]/[Child_Theme_Name]',
    __DIR__
);

/app/design/frontend/[Vendor]/[Child_Theme_Name]/theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
     <title>Child Theme Name</title>
     <parent>[Vendor]/[Parent_Theme_Name]</parent>
     <media>
         <preview_image>media/preview.jpg</preview_image>
     </media>
 </theme>

In the admin, I have selected that child theme and then cleared all the cache

Design Schedule

Unfortunately, the product detail page then doesn't change. If I make that change in the parent theme the product detail changes but it naturally affects all products which I don't want.

Can anyone advise on what I am doing wrong?

1 Answer 1

0

No need for a child theme. Just rename your layout file like this: catalog_product_view_id_{id}.xml

Source: https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/product-layouts.html

Or create a layout handle catalog_product_view_special.xml with your special layout and apply it on your products using <update handle="catalog_product_view_special"/>

HTH, Tom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.