Virtual Themes - AKA: A Headache¶
Virtual themes are not something well documented but can be a massive headache when encountered.
The Basics¶
Let's start with the basics;
There are technically three theme variations in Magento 2: 1. Physical 1. The standard theme - it lives in app/design or in a vendor module 2. Virtual 1. An extremely undocumented theme and the topic of this page 3. Staging 1. This seems to be related to the Enterprise edition of magento and is therefore not worth discussing on most occasions.
We can discard the 1st type, Physical, these are well documented and pretty obvious. We can also discard the 3rd type, Staging, this is an EE functionality so is beyond the scope of this document, you can find a link to some documentation for it at the bottom of this page if you require it.
So we are left with the Virtual type.
It is unclear what the intended purpose of Virtual themes is, it is possibly designed to be a temporary theme that you have active over certain promotions or periods, think black Friday sales etc.
You cannot add these themes from the backend or in the codebase.
The only way that they seem to appear is when you are using a VCS and there is an active theme in the database
that does not exist in your current branch and then running a bin/magento
command such as setup:static-content:deploy
.
When this specific environment exists you will have a virtual theme as Magento cannot find your theme files.
This will result in an issue when you later attempt to modify the theme once the files are in place.
The only real way to then make this work is to change the type of that theme from 1
to 0
. This can be done simply
in the database with a simple query:
UPDATE theme SET type=0 WHERE theme_id=YOUR_THEME_ID;
You now have the theme set back to a physical theme and your layout changes should start taking effect.