Other than the installation of the sample data, you can also add data to your site after the software is set up. There are two methods to achieve this particular sample data;
- Using Composer
- Cloning Storage
Install Using Composer:
The installation of sample data is possible whenever you will have the Magento software in the following ways;
- Download a compressed archive from Magento:
If you are done with the downloading process of the archive from GitHub, it will not work because of the composer.json file doesn’t contain the repo.magento.com URL.
- Used composer create-project:
You may use this method to get the sample data for either Magento open source or the commerce, but you must use the authentication keys, for the installation of Magento.
You may also use Composer for installing the sample data, either before or after the installation of Magento. Moreover, there are some tasks available. Such as;
- In the case of a contributing developer, you have to refer to the installation of cloning repositories.
For installing sample data, use the command line; enter the following command as the Magento file system owner in the <magento_root> folder.
The authentication error might be the following:
The 'https://repo.magento.com/packages.json' URL required authentication.
You must be using the interactive console to authenticate
If the error comes, then you have to change to your Magento installation directory and run composer update. It will prompt you for your authentication keys.
Complete the Sample Data installation:
Once you are done with the download of sample data packages, you have to log in or switch to your Magento server, the Magento file system owner and then enter the following command in <magento_root> folder;
Install Sample Data By Cloning Storage:
In this topic, we are going to know how to clone and add Magento 2.3 Sample Data if you cloned the Magento GitHub repository. This method is only useful for contributing developers, i.e. developers who plan for the contribution of Magento 2 codebase.
In case, if you are not a contributing developer, choose one of the other options displayed in the table of contents present on the left side of the page. Contributing users can use the method of Magento 2.3 Install Sample Data in the following ways;
- You use Magento Open Source
- You cloned the Magento 2 repository
Clone The Sample Data Repository
Here, we will discuss the installation of Magento Sample data by cloning the sample data. For this, we can use the following steps;
- Clone with the SSH Protocol
- Clone with the HTTPS Protocol
Clone with the SSH Protocol:
For cloning the Magento Sample data, the GitHub repository is using the SSH protocols.
- First of all, you have to go to the Magento sample data repository in the web browser.
- Then, you will have to tap on the name of the branch, i.e. SSH from the link.
- Now, click on the clipboard to copy.
- You need to change the web server’s docroot directory.
- Basically, for CentOS, it is www/html/var and also for Ubuntu, it is www/var.
Now, enter git clone and paste the value that you obtained in the first step.
git clone firstname.lastname@example.org:magento/magento2-sample-data.git
Then wait for the repository for cloning on your server.
Cloning into 'magento2'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Now, check out the branch of the sample data repository that corresponds with the branch you used from the main Magento 2 repository.
To check out the correct branch, you have to follow the link given below;
git checkout 2.2.5
- Then convert into <magento_root>.
To create symbolic links between the files, enter the following link;
Php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="<path_to_your_magento_instance>"
- Then you have to wait for the next command.
- Now, check the file system permissions and ownership.
Clone with HTTPS Protocol:
The following are the steps for cloning the Magento sample data GitHub repository using the HTTPS protocol.
- First of all, go to the Magento sample data repository present in the web browser.
- Now, click on the HTTPS, located on the right side of the page under the clone URL field
- Go to the clipboard, and tap copy.
- Now change the web server docroot directory.
Here also, for CentOS, it is www/html/var and for Ubuntu, it is var/www.
- After entering the git clone, paste the value which you obtained from step 1.
- Now, wait for the repository for cloning on your server.
- Ensure that you check out the branch of the sample data repository with respect to the branch you used from the main Magento 2 repository.
- Now, convert it into <magento_root>.
For the creation of symbolic links, just enter the following commands;
php -f <sample-data_clone_dir>/dev/tools/build-sample-data.php -- --ce-source="<path_to_your_magento_instance>"
- Now, you have to wait for the next command.
Lastly, check the final section;
If the Magento 2 Sample Data Not Showing up even after the complete installation process, then you can also Remove Magento Sample Data and again reinstall those sample data after installation.
Here, data is being used by the Magento named as Sample data. Magento Sample Data includes a sample store. It consists of more than 250 products (about 200 of them are considered as configurable), CMS pages, banners, categories, and promotional price rules. Technically, this Sample data is defined as a set of regular Magento modules that can be deployed and installed together with the Magento instance.