LoginSignup
2
2

More than 3 years have passed since last update.

EC-CUBE4 でテスト用のデータを生成する

Posted at

EC-CUBE4 には沢山のテスト用ダミーデータを生成するコマンドが実装されています。

開発時にダミーデータが欲しい場合などに便利です。

下準備

EC-CUBE4 をインストールし、 composer install を実行してください.
(Composer がインストールされてない方はインストールしておいてください)

cd path/to/ec-cube
composer install

パッケージ版の場合は必要なライブラリが含まれていないため、このコマンドを実行する必要があります。
github から clone してきた場合は不要です。

ダミー画像生成機能を使用したい場合は、 PHP の GD Extension が必要です。

使用方法

以下のコマンドを実行します

bin/console eccube:fixtures:generate

デフォルトでは、以下のデータを生成します

  • 商品数: 100点
  • 会員数: 100名
  • 注文数: 会員1名につき10件

これらは、以下のようなパラメータで設定できます

bin/console eccube:fixtures:generate --customers=2 --orders=1 --products=10

生成した会員のパスワードは password です。
このデータを決して本番環境へ反映しないよう、くれぐれもご注意ください

大量のデータを生成したい場合

上記コマンドを何回か繰り返し実行することをおすすめします。

以下のように cron で 10分おきに実行してもよいでしょう。

crontab <<EOF
*/10 * * * * cd /path/to/ec-cube && bin/console eccube:fixtures:generate
EOF
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2