Install and use sample data

Out of the box Magento comes with a clean base vanilla install with no customers, categories or products. This is great and what you want if you are building a completely new install of Magento for a client, but if you are trying to learn Magento you'll probably want to be working with some kind of data to represent a real, actual store.

Module developers will typically always work with a base install of sample data so they can simulate their customer's stores. Magento comes with a base dataset of sample data which includes a sample customer, orders, products and categories. The products it comes with also simulate the many different product types within Magento, and provide some guidance in how to setup this product data for your own store.

Let's go ahead and install it with the Magento command line tool. Run

bin/magento sampledata:deploy

This will use Composer to install all of the dependencies needed for the official sample data set. This includes many various Magento modules that contain the scripts to install this data. After this line is ran, note that the sample data does not yet appear. This is because the modules installed contain database update scripts which were not yet triggered.

Magento triggers module database updates with the setup: upgrade command. So go ahead and type in

bin/magento setup:upgrad

This command will detect any database scripts which have not run yet, and run them. This is what installs all of the actual data in your store.

When it completes and we refresh our store, we should be able to see the sample data and browse around. The home page, category pages, and product pages are all populated with data. Note that there are products installed with all of the different product types so we can test all of the various functionality of these different types, and we can view product pages, test a checkout, and even place an order at this point.

Discussion

0 comments