Magento 2 Install / Uninstall Sample Data via Command Line
In this tutorial, we will talk about Install / Uninstall Sample Data via Command Line in Command Line Series. As you know, from Magento 2, they add many commands in bin/magento
. If you find it quite hard to understand this, I will try to make it easier for you to understand by the instructions to install and uninstall sample data via command lines.
Let’s start!
What is Magento 2 sample data?
For store owners, Magento 2 sample data is like a ready-made store out of the box. It includes sample products across categories, pre-populated customers, and even some sample orders. This lets you see how your store might look with the Luma theme and experiment with features like order processing and customer accounts. It’s essentially a training ground to get comfortable with managing your Magento 2 store before going live.
On the developer side, sample data becomes a valuable testing environment. Developers can use it to mimic a real store, testing their code changes and extensions without affecting a live site with real customer data. It also provides a foundation to explore core functionalities of Magento 2, like product data management and order workflows. By interacting with the sample data, developers gain a deeper understanding of how Magento 2 works and how their custom code might integrate with the platform.
Why do we need Magento 2 sample data?
Before selecting an eCommerce platform, online store owners must carefully assess three key factors: performance, user experience, and scalability. Having sample data is particularly vital for easily conducting performance and scalability tests on the store.
For instance, Magento 2 provides sample data that enables administrators to include approximately 250 sample products and organize them into different categories. This ample stock of sample products allows administrators to effectively test website performance. Consequently, rather than relying solely on integrating modules to enhance the shopping experience, administrators can proactively modify their websites based on these tests.
Install / Uninstall Sample Data via command line
Go to Magento admin root folder and show usages:
php bin/magento maintenance:enable
Result:
Usage:
sampledata:deploy [options]
Options:
--no-update Update composer.json without executing composer update
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Deploy sample data modules
Install Sample Data Syntax
php bin/magento sampledata:deploy [options]
By default, it will update latest version of sample data via composer, then install it.
You can disable it with parameter: --no-update
php bin/magento sampledata:deploy --no-update
Magento asks me enter Username and password like this:
Don’t worry, Go to Access Keys page and Create A New Access Key
Output:
Uninstall Sample Data Syntax
Go to Magento admin root folder and show usages:
php bin/magento sampledata:remove -h
Output:
Usage:
sampledata:remove [options]
Options:
--no-update Update composer.json without executing composer update
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Remove all sample data packages from composer.json
Syntax:
php bin/magento sampledata:remove [options]
How to update sample data?
To prepare the sample data for updating, include the subsequent command:
bin/magento sampledata: reset
After that, update the Magento application via composer.
That concludes the process of installing Magento 2 sample data. Once the sample data is installed on your Magento 2 website, you are free to test its functionality extensively using the test data. We trust that you will be able to complete this tutorial without encountering any difficulties.
Wrap up
That’s how you can easily install and uninstall sample data via command lines in Magento 2. I hope this tutorial is helpful for you. If you have any questions, please let me know. Thanks for reading!
- How to create a simple Hello World module for Magento 2
- Magento 2 Block Template Ultimate Guides
- How to Create Module in Magento 2
- How to Create Controller in Magento 2
- How to create CRUD Models in Magento 2
- How to Create Magento 2 Block, Layout and Templates
- Configuration - System.xml
- How To Create Admin Menu In Magento 2
- Admin ACL
- Admin Grid