0

I have made a theme that is a child to a customized theme that is a child of Luma.

My theme lives in:

app/design/frontend/{mycompany}/{mythemename}/

My themes parent lives in:

vendor/{vendorcompany}/{vendorthemedirectory}/

The parent is overriding:

Magento_Catalog/templates/product/view/gallery.phtml among other files, like so:

vendor/{vendorcompany}/{vendorthemedirectory}/Magento_Catalog/templates/product/view/gallery.phtml

I want to override this override but I can't seem get the directory structure of my child theme right or maybe I'm missing something else.

My first thought is to create it like so:

app/design/frontend/{mycompany}/{mythemename}/{vendorcompany}_{vendorthemedirectory}/Magento_Catalog/templates/product/view/gallery.phtml

But that doesn't seem to work. gallery.phtml is still loading from the parent. I've tried a few combinations of directory structure without luck. How do I override the override?

1 Answer 1

0

Hello Adam and welcome on Magento Stack Exchange.

Is your custom theme declared as a child of the parent?

For doing this you have to include in your custom theme's theme.xml this code:

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Your custom theme</title>
        <parent>Parent/theme</parent> <!-- You find the correct name in registration.php of parent theme -->
    <media>
        <preview_image>media/preview.png</preview_image>
    </media>
 </theme>

Once you ensured that you have correctly declared the dependency from parent theme, you should enable your custom theme from Content > Design > Configuration

Then put your file in this path: app/design/frontend/{mycompany}/{mythemename}/Magento_Catalog/templates/product/view/gallery.phtml

Hope this could help to point you on the right way

2
  • Thanks, my theme is declared as a child of the theme I am attempting to override and I have selected it in Content > Design > Configuration. I have rechecked my theme.xml and registration.php and believe they are correct. I think my issue is getting the correct directory structure for this specific case? I'm a little confused about overriding the override of Luma as it were. The theme displays but template tags show it is pulling gallery.phtml from the parent location when I'm trying to pull it from the child location.
    – Adam
    Commented May 7, 2020 at 22:57
  • Check my edit answer Commented May 8, 2020 at 4:55

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.