Magento 2 | Import sample products after magento install

January 17th, 2019

For testing purpose, i need a clean installation of Magento2, but what if, after installed the CMS, you remember that you need sample data too?
No panic, you can install it using client:

If you worker with docker or remote site, you need to connect the CLI to magento;

Remote | Positioning on root of Magento 2.

composer create-project --repository=https://repo.magento.com/ magento/project-community-edition=2.3.0 .

Docker | Positioning on root of Magento 2.

$ docker exec -it magento_2_webserver_1 /bin/bash

First of all check if your magento is in a “developer” mode; Do not install sample data if your Magento application is set for production mode.

bin/magento deploy:mode:show
or
php bin/magento deploy:mode:show

If all is right, you have a response like this :

Current application mode: developer. (Note: Environment variables may override this value.)

If not, you must switch to developer mode:

bin/magento deploy:mode:set developer

Now retry with

bin/magento deploy:mode:show

and you’ll see that magento was switch in ” application mode: developer “.

To install sample data using the command line, enter the following command as the Magento file system owner:

php /bin/magento sampledata:deploy

If you’re installing sample data after installing Magento, you must also run the following command to update the database and schema:

php /bin/magento setup:upgrade

For do that you need to authenticate:

composer update

It’ll ask to inserted the credential from https://developer.magento.com – Access Keys.
Now you need to complete the sample data installation:

php /bin/magento setup:upgrade

That’s all
Navigate to the Magento index and reload the page.
If all it’s right you’ll see something like this image:

A clean magento installation with sample data.

That’s all