Deploying Sample Data on Magento 2.0 via CLI

posted in: Ecommerce, Magento 2.0 | 0

Magento provides Sample Data for Magento 2.0 installation. Deploying Sample Data on Magento 2.0 is helpful if you want to try out Magento 2.0 and explore new features. Sample data is an additional package and can be installed over your existing installation via Magento 2.0 CLI. You could also deploy it via Magento GitHub repository.

Here’s what the Sample Data Contains:

  1. More than 250 products with about 200 products being configurable products.
  2. Categories
  3. Promotional Prices
  4. CMS pages and promotional pages
  5. Banners and all other essential Store setup.

Prerequisites for Deploying :

  1. You must have Magento 2.0 installed.
  2. Shell Access to access Magento CLI

Deploying Sample Data on Magento 2.0 installation via CLI:

Step 1:

Navigate to bin directory and verify if Magento CLI is accessible by using

[bash] php magento

Note: If you are doing this on shared hosting where or if your server’s default PHP version is less than 5.6 you might encounter an error.

[bash] "Parse error: syntax error, unexpected ‘[‘, expecting ‘)’ in /home /public_html/magento/bin/magento on line 22"

In that case use full path of your php (greater than 5.6) installation

[bash]/usr/local/php56/bin/php-cli magento[/bash]
Step 2:

Use the following command to deploy Sample Data.

[bash]php magento sampledata:deploy[/bash]

Deploying Sample Data Magento 2.0 via CLI

If you are asked for authentication, enter your Public Key as username and Private key as Password. You could get these keys from MagentoConnect , Refer Installing Magento 2.0 for more information.

Errors while Deploying:

Usually memory_limit is set to 256 MB php.ini file and that might cause an issue while deploying Sample Data.

Memory size exhausted fatal error

A simple fix for this would be editing your magento file and increasing your memory_limit. Just add the following line at the start of magento file and you are good to go.

[php]ini_set(‘memory_limit’, ‘1024M’);[/php]

Alternate Ways to install

You could also download Magento installation archive from Magento Download Page with Sample Data.

Leave a Reply

Your email address will not be published. Required fields are marked *