Categories


Archives


Recent Posts


Categories


N98-magerun: Customer Commands

astorm

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@example.com        | John | Doe   | base |
| 2 | December23559PM@example.com | Alan | Storm | base |
| 3 | March18947PM@example.com    | Alan | Storm | base |
| 4 | March22235PM@example.com    | 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
Email: December23559PM@example.com
[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                     | December23559PM@example.com |
| 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 December23559PM@example.com 1
$ n98-magerun.phar customer:info December23559PM@example.com 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
Email: December23559PM@example.com
Password:password12345
[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
Email: April191119AM@example.com
Password: password12345
Firstname:Robert
Lastname:Hoffner
[1] base - Main Website
[2] second_website - Second Website
Please select a website: 1
Customer April191119AM@example.com 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 dedric.koch@example.org with password qz4mDjct successfully created
Customer cwuckert@example.com with password Nz!g_?WN successfully created
Customer karl.shanahan@example.com with password hhJyLppA successfully created
Customer johnston.buddy@example.org with password h$6$MfZy successfully created
Customer quitzon.rhett@example.com 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 Николета.Невенић@example.com with password !-..=94d successfully created
Customer Дафина.Лазић@example.com with password NyEm8!W- successfully created
Customer Вуча.Матушић@example.com with password 6R66GZC* successfully created
Customer Ђурисава.Комленић@example.org with password Yy?uPGj7 successfully created
Customer Алекса.Делић@example.com 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
...
Help:
 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 © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 19th April 2013

email hidden; JavaScript is required