Magento – Magento 2 – Creating a child theme

magento2parent-child-themetheme

I purchased a theme for a Magento 2 website. I know want to create a child theme to modify some of the styles, etc.

The theme purchased is called Porto and resides in

/app/design/frontend/Smartwave/porto 

So I created a directory

/app/design/frontend/Smartwave/porto_child

I then created a theme.xml file with the below contents

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Proto Child</title> <!-- your theme's name -->
    <parent>Smartwave/porto</parent> <!-- the parent theme, in case your theme inherits from an existing theme -->
    <media>
        <preview_image>media/preview.jpg</preview_image> <!-- the path to your theme's preview image -->
    </media>
</theme>

I then created a registration.php file

  <?php
      /**
        * Copyright © 2015 Magento. All rights reserved.
        * See COPYING.txt for license details.
        */
       \Magento\Framework\Component\ComponentRegistrar::register(
          \Magento\Framework\Component\ComponentRegistrar::THEME,
          'frontend/Smartwave/porto_child',
          __DIR__
        );

I also created a directory called media and put a preview.jpg in there
now when I go to the admin panel I get an error when I view the log in the var/report folder I see an error that says

 a:4:{i:0;s:107:"File '/var/www/app/design/frontend/Smartwave/porto_child/media/preview.jpg' does not exists."

When I SFTP to the directory I see the file!

When I run (on the command line)

mage setup:upgrade

I get a message that says

[Exception] File'/var/www/app/design/frontend/Smartwave/porto_child/media/preview.jpg' does not exists.

Also When i run
sudo bin/magento setup:static-content:deploy -t Smartwave/porto_child

[InvalidArgumentException] Smartwave/porto_child argument has invalid value, available themes are: Magento/blank, Magento/luma, Magento/backend, Smartwave/porto_rtl, Smartwave/porto

Best Answer

Check if the path really exist and run these commands below to give permit to folders and do a deploy, if have some problem will show up with the description:

alias mage="php -d memory_limit=-1 -f bin/magento"

chmod -R 775 pub/static/ var/ pub/media/ &&
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/tmp/ var/generation/ pub/static/frontend/ ;
mage cache:clean &
mage cache:flush &
mage indexer:reindex &
mage setup:upgrade &&
mage setup:static-content:deploy -t Smartwave/porto_child
mage setup:db-data:upgrade &&
mage dev:source-theme:deploy &&
chmod -R 775 pub/static/ pub/media/ var/
Related Topic