38

I want to install sample-data after successfully Magento setup. What is the process of installing the sample-data after Magento installation in Magento2?

16 Answers 16

48
  1. Install sample data modules:

    • Using composer:

      1. Add dependencies to the composer.json:

        composer require magento/module-bundle-sample-data magento/module-widget-sample-data magento/module-theme-sample-data magento/module-catalog-sample-data magento/module-customer-sample-data magento/module-cms-sample-data  magento/module-catalog-rule-sample-data magento/module-sales-rule-sample-data magento/module-review-sample-data magento/module-tax-sample-data magento/module-sales-sample-data magento/module-grouped-product-sample-data magento/module-downloadable-sample-data magento/module-msrp-sample-data magento/module-configurable-sample-data magento/module-product-links-sample-data magento/module-wishlist-sample-data magento/module-swatches-sample-data magento/sample-data-media magento/module-offline-shipping-sample-data --no-update
        
      2. Run:

        composer update
        
    • Using magento:

      1. Deploy sample data:

        bin/magento sampledata:deploy
        
  2. Enable sample data modules (it's important!):

    bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData
    
  3. Remove old files:

    rm -rf var/cache/* var/page_cache/* var/generation/*
    
  4. Upgrade magento files:

    bin/magento setup:upgrade
    
  5. Recompile files:

    bin/magento setup:di:compile
    
  6. Do reindex:

    bin/magento indexer:reindex
    
  7. Deploy static content:

    bin/magento setup:static-content:deploy
    
4
  • 1
    need to run bin/magento setup:di:compile after bin/magento setup:upgrade
    – hkguile
    Commented Jul 27, 2016 at 9:20
  • @hkguile Thank you for information. I have updated the answer. Commented Jul 27, 2016 at 9:38
  • @Gem Sorry about that, but I did not work with Magento under Windows :( I think all commands are similar, just use a backward slash and correct paths to the executable php. Commented Dec 18, 2018 at 10:38
  • @SiarheyUchukhlebau Thanks for your response i tried all possibilities almost 4 days, still error completely sick with Magento 2.3.
    – Gem
    Commented Dec 18, 2018 at 11:41
45

download sample data:

php bin/magento sampledata:deploy

Then install sample data:

php bin/magento setup:upgrade

https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/next-steps/sample-data/composer-packages

2
  • 4
    I have got an error message after trying the above code. "Your requirements could not be resolved to an installable set of packages." Problem 1 - magento/sample-data 0.42.0-beta2 requires magento/sample-data-media ~0.42.0-beta1 -> no matching package found. - magento/sample-data 0.42.0-beta2 requires magento/sample-data-media ~0.42.0-beta1 -> no matching package found. - Installation request for magento/sample-data 0.42.0-beta2 -> satisfiable by magento/sample-data[0.42.0-beta2].
    – Ranjit
    Commented Feb 26, 2016 at 12:25
  • 4
    Great answer! The only thing I would add is to remember that when it asks you to login this is not asking for your credentials to magento.com, but you need to generate a public and private key and then use that for the username and password.
    – KyleBunga
    Commented Jul 17, 2017 at 1:28
10

You can use command line to install sample data by going to magento 2 root folder. Then,

  1. download sample data: $php bin/magento sampledata:deploy

  2. install sample data: $php bin/magento setup:upgrade

Reference: http://devdocs.magento.com/guides/v2.0/install-gde/install/sample-data-after-magento.html

3

I just ran through this: The sample data won't work if your on the development branch which is the default on github. Grab the master instead.

git clone -b master https://github.com/magento/magento2.git

Then update your composer.json with the sample data package. From the Docs ->

Add "minimum-stability": "beta", before license which now looks like

"name": "magento/project-community-edition",
"description": "Magento project (Community Edition)",
"type": "project",
"minimum-stability": "beta",
"version": "1.0.0-beta",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],

And run composer config repositories.magento composer http://packages.magento.com Then composer require magento/sample-data:~1.0.0-beta

And now that your sample data package is installed, update your database with

<path to Magento 2 bin dir>/magento setup:upgrade

<path to Magento 2 bin dir>/magento sampledata:install <your Magento administrator user name>

3
  • <path to Magento 2 bin dir>/magento setup:upgrade this command not working. please help to me how to can work ? Commented Sep 23, 2015 at 13:02
  • From you project root, the bin directory will be under the app directory. Inside is the php file Magento which loads the Magento CLI application. Do you see it? Can you extrapolate on how it's not working?
    – SpaceJam
    Commented Sep 23, 2015 at 15:53
  • problem with mangento2 git branch. I have installed develop branch, develop brach not working installation sample-data. working in magento master brach but command is <magento root directory > php bin/magento magento setup:upgrade command. Commented Sep 24, 2015 at 6:38
3

First install magento2. After just run following command to install sample data.

1) Goto your installation directory:

root@prince:/var/www/html/magento2#

2) After, Run this command

php bin/magento sampledata:deploy

3) Now login to magentocommerce to get username and password

https://www.magentocommerce.com/magento-connect/customer/account/login/

4) Go to developers->Secure keys, Generate new key or use existing key

-> Use public key as Username and Private key as Password

5) Now run this command for recompile code, upgrade database and clear cache

php bin/magento setup:upgrade

Now run this command for reindex

php bin/magento indexer:reindex

At last give permission of files and folders

3

This is simple you can use by the composer , just need go on the root directory and

use below command to download sample data:

php bin/magento sampledata:deploy

Then install sample data

php bin/magento setup:upgrade

you can also clean the cache or do re-indexing if data not showing on the website .

using below commands : php bin/magneto indexer:reindex

1
  • Seems the same as this
    – Suraj Rao
    Commented Oct 9, 2019 at 16:32
2

Did you already solve this? If not, see this: http://devdocs.magento.com/guides/v2.0/install-gde/install/sample-data.html#instgde-install-sample-enable-after

2

you can use this alternative :

composer config repositories.0 composer https://repo.magento.com

and then:

bin/magento sampledata:deploy

you'll be prompted for username/password : use public_key/private_key from your magento marketplace account

2
  • @abilasher I just did, you can check ! Commented Jan 26, 2020 at 23:06
  • thank you very much . But there is a problem in that . I already post it there Commented Jan 27, 2020 at 9:12
1

Magento sample-data installation after magento setup(working in master branch - Solution works for old version - beta version).

Command is working like

<path to Magento 2 bin dir>php magento setup:upgrade

<path to Magento 2 bin dir>php magento sampledata:install <your Magento administrator user name>

Command is like not working.

<path to Magento 2 bin dir>/magento setup:upgrade

<path to Magento 2 bin dir>/magento sampledata:install <your Magento administrator user name>
1

Deploy Sample Data from Composer Repository

In the Magento root directory, run following command:

# bin/magento sampledata:deploy

This command collects the dependencies from the suggest sections of the composer.json files of modules, which suggest to install sample data

To deploy sample data from the Magento composer repository without Magento CLI:

Specify sample data packages in the require section of the root composer.json file, for example:

{
"require": {
    ...
    "magento/module-catalog-sample-data": "{version}",
    "magento/module-configurable-sample-data": "{version}",
    "magento/module-cms-sample-data": "{version}",
    "magento/module-sales-sample-data": "{version}"
    ....
}

}

Where version is the version of the packages; it should correspond to the version of the Magento instance.

0

Magento2 is very easy to install.

Step 1-: download the source code from github.

Step 2-: Extract the source code on your web root.

$ unzip magento2.zip 

Step 3-: Install dependencies via composer command.

$ cd /var/www/html/magento2/   
$ composer install

Step 4-: Set the require permission and ownership.

$ sudo chmod -R 775 /var/www/html/magento2/
$ sudo chown -R www-data:www-data /var/www/html/magento2/

Magento2 instance is ready to install. Open the web browser, use you server ip or localhost.

0

If you do not have Magento repository in your composer.json file than the above code will not work. Try running

composer config repositories.magento composer https://repo.magento.com

to add a magento repository in your composer.json file and than run

php magento sampledata:deploy

0

Try this one.

Run Following command in terminal

php bin/magento sampledata:deploy //to deploy sample data in magento2

php bin/magento setup:upgrade //to upgrade modules and to run setup files

php bin/magento setup:di:compile //to compile files

php bin/magento indexer:reindex //index flat tables and product price

php bin/magento setup:static-content:deploy // to regenerate static files

Give Full permission to Var Folder 777.

Load site in browser

0

I struggled for ages with this until I used this method to install sample data. what a tool I am ;)

https://devdocs.magento.com/guides/v2.2/install-gde/install/sample-data-after-clone.html

0

The following will solve your problem

make sure you're in you Magento install directory and you have write access: then run step by step

php bin/magento sampledata:deploy

php bin/magento setup:upgrade

if you don't have your keys please click authenticate and follow to guide to obtain your keys

if you get the following error

[Composer\Downloader\TransportException] The 'https://repo.magento.com/packages.json' URL required authentication. You must be using the interactive console to authenticate

then check which directory you in, if your are in the magento installed directory then run

composer update

and php bin/magento setup:upgrade

-1

We can install the sample data using terminal after Magento2 installation. We need to Run the below command.

  1. php bin/magento c:c
  2. php bin/magento sampledata:deploy
  3. php bin/magento s:up
  4. php bin/magento s:d:c
  5. php bin/magento s:s:d
  6. sudo chmod -R 777 var var/* pub pub/static/* generated generated/*

For moreinformation, check How to install sample data in Magento2

Not the answer you're looking for? Browse other questions tagged or ask your own question.