Magento sample data provides a Luma theme-based storefront. It has 250 products, CMS pages, banners, categories, promotional price rules, etc.
Although installing the sample data is optional, it can be used as a test environment. Let’s dive straight into the topic and learn how to install sample data in Magento 2.
- Log in to your Magento server over SSH and navigate to the root directory of your Magento 2 store.
- Enable developer mode by using this command:
php bin/magento deploy:mode:set developer
- Run the following command to install the sample data:
php bin/magento sampledata:deploy
You’ll see the following authentication error if the Access Keys aren’t stored:
[Composer\Downloader\TransportException] The 'https://repo.magento.com/packages.json' URL required authentication. You must be using the interactive console to authenticate
In that case, go to your Magento marketplace account and click on My Profile > Access Keys.
Copy and paste the Public Key as the Username in the SSH terminal. Similarly, use the Private Key as the Password and hit the Enter key.
If there’s no access key available, use the Create a New Access Key button to generate a new key.
Enter the Y key after receiving the following prompt to start the installation process:
Do you want to store credentials for repo.magento.com in /htdocs/sampledata/var/composer_home/auth.json ? [Yn]
- Execute the following commands to update the database, recompile the code, and deploy static view files:
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f
- Open your front end and verify sample data.