Recent Posts


N98-magerun: Customer Commands


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

This article is part of a longer series covering the n98-magerun power tool

Similar to the already covered admin commands, n98-magerun also has commands for managing customer accounts.

$ n98-magerun.phar list customer
Available commands for the "customer" namespace:
  customer:change-password   Changes the password of a customer.
  customer:create            Creates a customer.
  customer:create:dummy      Creates a dummy customers.
  customer:info              Show infos about a customer
  customer:list              Lists customers

The customer:list command allows you to view all the customers in the system.

$ n98-magerun.phar customer:list
|   | email                       | fir  | last  | web  |
| 1 |        | John | Doe   | base |
| 2 | | Alan | Storm | base |
| 3 |    | Alan | Storm | base |
| 4 |    | Alan | Storm | base |

The customer:info command will, via interactive prompts, allow you to fetch information about a specific customer based on their email address and website_id.

$ n98-magerun.phar customer:info
[1] base - Main Website
[2] second_website - Second Website
Please select a website: 1
| Attribute                 | Value                       |
| Associate to Website      | Main Website                |
| entity_id                 | 2                           |
| entity_type_id            | 1                           |
| attribute_set_id          | 0                           |
| Email                     | |
| Customer Group            | General                     |
| Create In                 |                             |
| Created At                | 2012-12-24 01:59:59         |
| updated_at                | 2012-12-24 01:59:59         |
| is_active                 | 1                           |
| disable_auto_group_change | 0                           |
| First Name                | Alan                        |
| Last Name                 | Storm                       |
| Created From              | English                     |

The email address and website_id (or website code) may also be passed in via arguments to the customer:info command to avoid the interactive prompts.

$ n98-magerun.phar customer:info 1
$ n98-magerun.phar customer:info base

Just like the admin commands, there’s also a command to change a customer’s password. This is extra useful if you’ve inherited a Magento system and need to log in as a particular user in your development environment.

$ n98-magerun.phar customer:change-password
[1] base - Main Website
[2] second_website - Second Website
Please select a website: 1
Password successfully changed

You may also use the customer:create command to quickly create a new customer account.

$ n98-magerun.phar customer:create
Password: password12345
[1] base - Main Website
[2] second_website - Second Website
Please select a website: 1
Customer successfully created

Interestingly, if customer:create is too much typing for you, there’s also a the customer:create:dummy command. This command will allow you to create an arbitrary number of fake (or “dummy”) user accounts. The customer:create:dummy command doesn’t have interactive prompts for all its arguments, so you’ll need to supply them on the command line

$ n98-magerun.phar customer:create:dummy 5 en_US 1

The first argument (5 above) is the number of dummy accounts you want to create. The second argument (en_US above) is a valid language locale , and the final argument (1 for us) is the website_id the customer should be created with.

You’re probably wondering about the locale requirement. This is required by the PHP Faker library, which is used to create the fake data that populates the customer data. For example, with the en_US value used above

$ n98-magerun.phar customer:create:dummy 5 en_US 1
Customer with password qz4mDjct successfully created
Customer with password Nz!g_?WN successfully created
Customer with password hhJyLppA successfully created
Customer with password h$6$MfZy successfully created
Customer with password X2FW?LTT successfully created    

the email addresses created are all valid for the en_US locale. However, if we change that to sr_RS

$ n98-magerun.phar customer:create:dummy 5 sr_RS 1
Customer Николета.Невенић with password !-..=94d successfully created
Customer Дафина.Лазић with password NyEm8!W- successfully created
Customer Вуча.Матушић with password 6R66GZC* successfully created
Customer Ђурисава.Комленић with password Yy?uPGj7 successfully created
Customer Алекса.Делић with password zmv6sSh? successfully created

we’ll end up with email addresses more appropriate for a serbian locale. If you’re having trouble remembering a particular the locale ID code, the help for the dump command has you covered.

$ n98-magerun.phar help customer:create:dummy
 Supported Locales:

 - cs_CZ
 - ru_RU
 - bg_BG
 - en_US
 - it_IT
 - sr_RS
 - sr_Cyrl_RS
 - sr_Latn_RS
 - pl_PL
 - en_GB
 - de_DE
 - sk_SK
 - fr_FR
 - es_AR
 - de_AT

The customer:create:dummy command can be a huge boon when setting up development and/or staging stores.

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 19th April 2013