このコマンドを使用する前に、テーマの相対パスを把握しておく必要があります。 テーマは、のサブディレクトリに配置されます。 <magento_root>/app/design/<area name>
. テーマのパスは、領域 ( frontend
(ストアフロントテーマの場合)または adminhtml
( 管理者 テーマ )。
例えば、Luma へのパス テーマ Adobe CommerceとMagento Open Source frontend/Magento/luma
.
テーマについて詳しくは、 テーマ構造.
このセクションでは、1 つ以上のテーマをアンインストールする方法について説明します。その際に、必要に応じてファイルシステムからテーマのコードを含めます。 最初にバックアップを作成して、後でデータを復元できます。
このコマンドは、アンインストールします のみ 指定されたテーマ composer.json
;言い換えれば、次のように提供されるテーマ コンポーザー パッケージ。 テーマが Composer パッケージでない場合は、次の方法で手動でアンインストールする必要があります。
の更新 parent
ノード情報 theme.xml
をクリックして、テーマへの参照を削除します。
ファイルシステムからテーマコードを削除する。
コマンドの使用:
bin/magento theme:uninstall [--backup-code] [-c|--clear-static-content] {theme path} ... {theme path}
ここで、
{theme path}
は、テーマの相対パスで、領域名から始まります。 例えば、Adobe CommerceとMagento Open Sourceで提供される空のテーマへのパスが frontend/Magento/blank
.--backup-code
後述の段落で説明するように、コードベースをバックアップします。--clear-static-content
生成されたクリーン 静的表示ファイル:静的ビューファイルが正しく表示されるために必要です。このコマンドは、次のタスクを実行します。
指定したテーマのパスが存在することを確認します。そうでない場合、コマンドは終了します。
テーマが Composer パッケージであることを確認する。そうでない場合、コマンドは終了します。
依存関係をチェックし、未満の依存関係がある場合はコマンドを終了します。
この問題を回避するには、すべてのテーマを同時にアンインストールするか、まずテーマに応じてをアンインストールします。
テーマが使用されていないことを確認します。使用中の場合、コマンドは終了します。
テーマが仮想テーマのベースでないことを確認します。仮想テーマのベースの場合、コマンドは終了します。
ストアをメンテナンスモードにします。
If --backup-code
を指定し、コードベースをバックアップします ( pub/static
, pub/media
、および var
ディレクトリ。
バックアップファイル名は次のとおりです。 var/backups/<timestamp>_filesystem.tgz
バックアップは、 magento setup:rollback
コマンドを使用します。
テーマを theme
データベーステーブル。
次を使用して、コードベースからテーマを削除する composer remove
.
次をクリーンアップ: キャッシュ.
生成されたクラスをクリーン
If --clear-static-content
が指定され、クリーン 生成された静的ビューファイル.
例えば、別のテーマが依存するテーマをアンインストールしようとすると、次のメッセージが表示されます。
Cannot uninstall frontend/ExampleCorp/SampleModuleTheme because the following package(s) depend on it:
ExampleCorp/sample-module-theme-depend
その 1 つは、次のコードベースのバックアップと同時に、両方のテーマをアンインストールする方法です。
bin/magento theme:uninstall frontend/ExampleCorp/SampleModuleTheme frontend/ExampleCorp/SampleModuleThemeDepend --backup-code
次のようなメッセージが表示されます。
Code backup is starting...
Code backup filename: 1435261098_filesystem_code.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Code backup path: /var/www/html/magento2/var/backups/1435261098_filesystem_code.tgz
[SUCCESS]: Code backup completed successfully.Removing frontend/ExampleCorp/SampleModuleTheme, frontend/ExampleCorp/SampleModuleThemeDepend from database
Loading composer repositories with package information
Updating dependencies (including require-dev)
Removing frontend/ExampleCorp/SampleModuleTheme, frontend/ExampleCorp/SampleModuleThemeDepend from Magento codebase
- Removing ExampleCorp/sample-module-theme-depend (dev-master)
Removing ExampleCorp/SampleThemeDepend
- Removing ExampleCorp/sample-module-theme (dev-master)
Removing ExampleCorp/SampleTheme
Writing lock file
Generating autoload files
Cache cleared successfully.
Alert: Generated static view files were not cleared. You can clear them using the --clear-static-content option.
Failure to clear static view files might cause display issues in the Admin and storefront.
Disabling maintenance mode