Magento 2 sample data: what is it, why need it and how to install

magento 2 sample data

Magento 2 sample data is a test sample data based on the Luma theme with sample products, categories, customers’ data, etc. The objective of the sample data after you have installed Magento 2 is to use it as a test environment where you can tweak the orders, prices, add products, manage inventory, test the pricing rules, and so on

Magento is one of the most popular eCommerce solutions in the market. Built as an open-source platform, Magento supports merchants to customize the website flexibly to meet their business requirements. The platform offers sample data to test the store performance and scalability, thus allowing store owners to bring a great experience for their customers.

What is Magento 2 sample data?

For store admins, Magento 2 sample data provides online store owners with a storefront based on the Luma theme outfitted with products, categories, customer registration, and so on. It functions just like a Magento storefront and you can manipulate prices, inventory, and promotional pricing rules using the Magento Admin.

For developers, sample data is a set of common Magento modules, which can be deployed and installed together with the Magento instance, or later in the scope of upgrade. That is the reason why installing sample data is optional.

Why Need Magento 2 Sample Data?

There are 3 crucial factors that an online store owner must consider before opting for any eCommerce platform. These factors include performance, user experience, and scalability. The sample data is very important when you need a tool to conduct the store’s performance and scalability tests easily.

Specifically, Magento 2 sample data offers the admin store to add nearly 250 sample products and categorize them into various groups. The number of sample products in stock is enough for the admin to test the website performance. Thus, instead of integrating modules, which helps optimize the shopping experience, they can modify their website in advance.

How to install Magento 2 sample data?

Let’s learn to install Magento sample data.

1. Launch SSH terminal to connect your Magento website

2. Move to the root directory (public_html) of your website

magento 2 sample data


3. Run the following CLI content to install Magento 2 sample data.

php bin/magento sampledata:deploy

magento 2 sample data


4. To authenticate from, type your username, and password.

magento 2 sample data


5. Log in to your Magento marketplace account and click My Profile

magento 2 sample data


6. Click  Access Keys in My Products section

magento 2 sample data


If you already have an access key, you can use that. Otherwise, you need to generate a new key: Create A New Access Key.

create a new access key magento 2 sample data

There are two types of keys: a public and a private one.

  • Public Key: Use this public key as your username.
  • Private: Use this private key as your password.

7. Move back to the SSH terminal and type your username, password and Type ‘Y’:

magento 2 sample data


8. Enter to start the Magento 2 sample data installation process.

magento 2 sample data


9. After installing Magento 2 sample data, run the following commands one by one.

  1. php bin/magento setup:upgrade
  2. php bin/magento setup:di:compile
  3. php bin/magento setup:static-content:deploy -f

10. Move to your store’s front page.

magento 2 sample data


After that, you can go to the frontend to see if the sample works

How to remove sample data modules?

There is currently no way to uninstall sample data. So we will guide you on how to remove sample data modules from the Magento installation composer.json. However, this way does not remove sample data from the database.

1.Log in to the Magento server as a user with permission to type to the Magento file system. If the Magento file system does not allow admin to log in, you can do the following:

sudo -u <Magento file system owner>  <command>

2. Add <magento_root>/bin to your system PATH, to run Magento commands from any directory. Sample bash shell for CentOS:

export PATH=$PATH:/var/www/html/magento2/bin

3. Optionally, the commands can be run in the below ways:

  • <magento_root> is a subdirectory of your web server docroot.
  • cd <magento_root>/bin and run them as ./magento <command name>
  • <magento_root>/bin/magento <command name>

4. Follow the command line:

bin/magento sampledata:remove

How to update sample data?

This command helps you to update sample data before you update the Magento application. To prepare sample data for updating, add the following command:

bin/magento sampledata:reset

After that, update the Magento application via composer.

That was all about Magento 2 sample data installation. Once you have installed sample data on Magento 2 website, you can test the function with the test data as much as you want. Hope you guys can complete this tutorial without any difficulty. If you want to understand more about Magento you can read our Magento platform article for more detail, also remember to check out our Magento 2 extensions and our Magento 2 themes to support your website.

280 Total Views 2 Views Today