How To Install Sample Data In Magento 2

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.

There are two methods to install Magento 2 sample data:

  1. Install using Magento CLI
  2. Install by cloning repositories

You can bookmark this Magento 2 sample data installation guide for future reference too.

Methods to install Magento 2 Sample Data:

  1. Install using Magento CLI

    1. Export Magento CLI’s path with the below command
    2. Change your current directory to Magento’s Webroot
    3. In case you get the error of URL authentication to repo.magento.com, execute “composer update” command. For that, you’d require the username and password from the Magento Connect Account section.
    4. Recompile the code and clear the cache
  2. Install by cloning repositories

    1. Cloning with SSH Protocol
      1. Visit Magento sample data repository
      2. Next to the name of the branch, click SSH from the list.
      3. Click Copy to clipboard
      4. Go to your web server’s docroot directory. For Ubuntu, the directory is /var/www and for CentOS it’s /var/www/html.
      5. Enter git clone and paste the value from the previous step. For example,
        git clone [email protected]:magento/magento2-sample-data.git
      6. Wait for the repository to clone on your server.
      7. Make sure to check out the branch of the sample data repository that corresponds with the branch you used from the main Magento 2 repository.
        For eg: if the branch of Magento repository is 2.3.3 develop, the sample data branch should be 2.3.3
        You can check the correct branch using the below command from the sample data repository’s root directory – $git checkout 2.3.3
      8. Change to <magento_root>
      9. Create symbolic links between the files you just cloned with the below command:
    2. Cloning with HTTPS Protocol
      1. Visit Magento sample data repository
      2. Click HTTP under the clone URL field on the right side
      3. Click Copy to clipboard
      4. Change to your web server’s docroot directory. For Ubuntu, it’s /var/www and for CentOS it’s /var/www/html.
      5. Enter git clone and paste the value from the previous step. For example,
        git clone [email protected]:magento/magento2-sample-data.git
      6. Wait for the repository to clone on your server.
      7. Make sure to check out the branch of the sample data repository that corresponds with the branch you used from the main Magento 2 repository.
        For eg: if the branch of Magento repository is 2.3.3 develop, the sample data branch should be 2.3.3
        You can check the correct branch using the below command from the sample data repository’s root directory – git checkout 2.3.3
      8. Change to <magento_root>
      9. Create symbolic links between the files you just cloned with the below command:

Set File System Ownership and permissions:

  1. Go to your sample data clone directory
  2. Set ownership
  3. Set system permission
  4. Clear cache
  5. Update database

That was all about Magento 2 sample data installation. Once you have installed sample data in Magento 2 store, you can test the functionalities with the test data as much as you want.

If you have any doubts in steps to install sample data in Magento 2, do mention them in the Comments section below. I’d be glad to help you.

Do not forget to share the tutorial via social media.

Thank you.

 

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 7 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.