38

In the theme table there is a type field with 3 possible values: physical, virtual and staging.

When to use physical virtual and staging theme?

When I extended luma theme my new theme appear in theme table as virtual type. But looks like this type doesn't allow overriding some files, and only changing theme type from virtual to physical let me extend for example Magento_Theme package.

2
  • 1
    Good Question May be not sure 0: Physical - Magento Default Theme (Example: Magento Blank, Magento Luma, Magento 2 Backend) 1: Virtual - Custom Theme which is created by you (custom) which has parent as Default Theme (Example: My Theme) 2: Staging - ?
    – Jackson
    Oct 6, 2016 at 4:10
  • 1
    Refer to vendor\magento\module-theme\Model\Theme\Registration.php /** Allowed sequence relation by type, array(parent theme, child theme) * @var array */ protected $_allowedRelations = [ [ThemeInterface::TYPE_PHYSICAL, ThemeInterface::TYPE_VIRTUAL], [ThemeInterface::TYPE_VIRTUAL, ThemeInterface::TYPE_STAGING],]; /** Forbidden sequence relation by type ** @var array*/ protected $_forbiddenRelations = [[ThemeInterface::TYPE_VIRTUAL, ThemeInterface::TYPE_VIRTUAL],[ThemeInterface::TYPE_PHYSICAL, ThemeInterface::TYPE_STAGING],];
    – Jackson
    Oct 6, 2016 at 4:28

2 Answers 2

44

There's 3 different types defined in Magento/Framework/View/Design/ThemeInterface:

  • Physical type
  • Virtual type
  • Staging type

Physical themes

Physical refers to the fact that those themes are defined by files. For example, the blank and luma theme are physically defined under app/design/frontend/

Virtual themes

This is yet unclear but I think virtual themes refer to themes you can create in the backend which extends existing physical themes but it seems like it's not fully implemented yet.

You can see that there's two tabs available in the edit section only for virtual themes which let you provides custom CSS and JS for a virtual theme.

I reckon a virtual theme would be something you setup temporarily (like Christmas theme) for a short period of theme and which requires only few design changes compared to the physical theme it extends.

There's no Add Virtual Theme button available yet but if you run the following SQL query you can setup a virtual theme and you'll see the CSS and JS tab when editing it:

INSERT INTO `theme` (`theme_id`, `parent_id`, `theme_path`, `theme_title`, `preview_image`, `is_featured`, `area`, `type`, `code`) VALUES (NULL, '1', NULL, 'test', NULL, '0', 'frontend', '1', 'test/test');

And here you go, two extra tabs and Save/Delete buttons:

enter image description here

Staging themes

I reckon staging themes are related to the Magento 2.1 EE staging feature:http://devdocs.magento.com/guides/v2.1/extension-dev-guide/staging/Staging.html

I assume you can have a staging theme when using a campaign but I'm not 100% sure.

3
  • 1
    You just solved my problem right here Raph! Thank you - Alvin :) Mar 20, 2018 at 3:35
  • 7
    I ran into an issue with the type column on the theme table: I created a theme and somehow the type value got set to 1 (instead of the default of 0). All of my LESS/JS changes worked, but Magento would not read any layout files from my theme until I changed the type value to 0. More on this here: nahuelsanchez.com/… Oct 10, 2019 at 16:30
  • 2
    Ran into the same problem too. I copied the theme files into the wrong directory and this somehow updated the type value in the db to 1 instead of 0. After I discovered that I copied the theme files to the wrong place I could not figure out why things were not working until I traced down the problem with Xdebug to the theme type being incorrect. Spent a better part of a day tracking this down. Magento really needs to stop doing crap like this. Sep 28, 2020 at 20:22
3

7 years later... Maybe someone will help this new answer.

(At least in Adobe Commerce 2.4.5)

As Raphael answered a few years ago, there are 3 types of themes:

  • Physical
  • Virtual
  • Staging

Physical themes:

Themes defined in files. For example: Luma or custom theme defined under app/design/.

Virtual themes:

Themes that exists in the database but not in files. This can be reproduced if we delete themes files of a existing theme or if we import a database dump with a theme installed whose files do not exist in our code.

enter image description here

enter image description here

Staging themes:

Are used to "Create 'staging' theme associated with current 'virtual' theme" (According to a vendor PHPDoc comment).

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.