Provide Magento Sample Data

Import Sample Data

A detailed step by step guide of a complete Pacemaker Import Community installation including a fresh Magento installation and sample data is available as a comprehensive guide in the general Pacemaker Guides section as well.

When this is the first import, the default import directory <magento-install-dir>/var/pacemaker/import must get created.

Navigate into working dir
cd <magento-install-dir>
Create var/pacemaker/import directory
mkdir var/importexport

All the files with the sample data (attribute-sets, attributes, categories, and products) have to get copied to this directory. The command to copy the sample data, including the images looks like this:

Copy Sample Data files to importexport directory
cp vendor/techdivision/import-sample-data/generic/data/attributes-set/add-update/*.csv var/importexport \
  && cp vendor/techdivision/import-sample-data/generic/data/attributes/add-update/*.csv var/importexport \
  && cp vendor/techdivision/import-sample-data/generic/data/categories/add-update/*.csv var/importexport \
  && cp vendor/techdivision/import-sample-data/generic/data/products/add-update/*.csv var/importexport
  • The import process only starts, when an OK flag file is available in the same directory where the CSV files are located.

  • The naming convention for the OK flag file MUST follow one of these naming conventions

<IMPORT-DIRECTORY>/<PREFIX>.ok
<IMPORT-DIRECTORY>/<PREFIX>_<FILENAME>.ok
<IMPORT-DIRECTORY>/<PREFIX>_<FILENAME>_<COUNTER>.ok

which results in one of

import-cli-simple/projects/sample-data/tmp/magento-import.ok
import-cli-simple/projects/sample-data/tmp/magento-import_20170203.ok
import-cli-simple/projects/sample-data/tmp/magento-import_20170203_01.ok

In case we’ve a bunch, the flag file MUST contain the name of the CSV files that have to be imported within the next iterations.

If the flag file would be named <magento-install-dir>/var/pacemaker/import/product-import_20161021-161909.ok for example and contains the following lines

product-import_20161021-161909_01.csv
product-import_20161021-161909_02.csv
product-import_20161021-161909_03.csv
product-import_20161021-161909_04.csv

the importer has to be invoked four times (because the example above is NO bunch), whereas on each innovation, the next file will be imported and removed from the flag file.

Have a look in the subdirectories of <magento-install-dir>/vendor/bin/techdivision/import-sample-data/ for a working examples.

Run the Import
vendor/bin/import-simple import:create:ok-file \
&& vendor/bin/import-simple import:attributes:set \
&& vendor/bin/import-simple import:attributes \
&& vendor/bin/import-simple import:categories \
&& vendor/bin/import-simple import:products

The first command creates the mandatory .OK file that signals, that all import artifacts are on-place and the second command finally starts the import with the add-update operation on your Magento 2 installation.

The import commands support an argument as well as several options.

In Case the imported Sample Data are not displayed in the Store, please run the Magento Indexer and clear all caches as well

Run indexer
bin/magento c:f && bin/magento indexer:reindex