テーマのアンインストール
このコマンドを使用する前に、テーマの相対パスを把握しておく必要があります。 テーマは、のサブディレクトリに配置されます。 <magento_root>/app/design/<area name>
. テーマのパスは、領域で始まるパスを指定する必要があります ( frontend
(ストアフロントテーマの場合)または adminhtml
(管理テーマの場合)。
例えば、Adobe CommerceとMagento Open Sourceで提供される Luma テーマへのパスが frontend/Magento/luma
.
テーマについて詳しくは、 テーマ構造.
テーマのアンインストールの概要
このセクションでは、1 つ以上のテーマをアンインストールする方法について説明します。その際に、必要に応じてファイルシステムからテーマのコードを含めます。 最初にバックアップを作成して、後でデータを復元できます。
このコマンドは、uninstalls を実行します。 のみ 指定されたテーマ 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 パッケージであることを確認します。そうでない場合、コマンドは終了します。
-
依存関係をチェックし、未満の依存関係がある場合はコマンドを終了します。
この問題を回避するには、すべてのテーマを同時にアンインストールするか、まずテーマに応じてをアンインストールします。
-
テーマが使用されていないことを確認します。使用されている場合は、コマンドが終了します。
-
テーマが仮想テーマの基本ではないことを確認します。仮想テーマの基本である場合は、コマンドが終了します。
-
ストアをメンテナンスモードにします。
-
次の場合
--backup-code
を指定し、コードベースをバックアップします (pub/static
,pub/media
、およびvar
ディレクトリ。バックアップファイル名は次のとおりです。
var/backups/<timestamp>_filesystem.tgz
バックアップは、
magento setup:rollback
コマンドを使用します。 -
テーマを
theme
データベーステーブル。 -
次を使用して、コードベースからテーマを削除する
composer remove
. -
キャッシュをクリーンします。
-
生成されたクラスをクリーン
-
次の場合
--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
<component root directory>/etc/di.xml
.