Installation

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

Install the Pacemaker Import Community and sample data

When you have got a full running Magento 2 instance, you additionally need to download the sample CSV import files from the repository techdivision/import-cli-simple.

Add the Pacemaker Import Community repository and the Sample data repository to your Magento installation:

Navigate into working dir
cd <magento-install-dir>
Install Pacemaker Import Community and sample data
cd <magento-install-dir> \
&& composer require techdivision/import-cli-simple \
&& composer require techdivision/import-sample-data

The Pacemaker CLI and the Sample Data files as well for your Magento 2 version will find place at listed locations in the current Magento instance under:

  • <magento-install-dir>/vendor/techdivision/import-cli-simple

  • <magento-install-dir>/vendor/techdivision/import-sample-data

At this time of the Sample data installation, the import data are only stored as CSV files.

the import must be initialized in a separate step

Import Sample Data

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