Install Guide for Magento 2 CE/EE + Pacemaker Import Community (CE) + example data step by step

gen_general-system-requirements-essentials In this Guide, you will find detailed information about the Pacemaker Import Community - Simple Console Tool installation and usage.

To give you a better impression, what is possible with Pacemaker, we provide a running example that is based on a Magento 2 Sample Data installation.

Follow the steps to delete, replace, add and update products including categories in a Magento 2 installation with the Sample Data provided by Magento.

  • You can find the sources for Magento 2 CE/EE 2 on the Magento 2 CE/EE website

  • It is best practice to download the complete package directly from the Magento 2 CE/EE website

Step 1: Download and Install a blank Magento 2 instance

The best way is to download the complete package of Magento 2 sources directly from the Magento website. A running system is required; please follow the Magento instructions to install your Magento 2 instance.

  • Requirements for a successful local Magento 2 CE/EE installation in the current version:

    • Composer

    • PHP >= 7.3

    • Local server to host a local instance

    • Local HTTPS support

    • If nessary, a Magento Marketplace Account to access the Magento Repository is needed as well

    • Follow the installation steps recommended by Magento to set up a Magento 2 CE/EE instance locally successfully.

Install the current version of Magento Community with Composer

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

Step 2: Preparation of the Magento 2 instance

The first step is to create the required database for the project.

There are several options available to do this:

Step 3: Create Database for Magento

Navigate into working dir
cd <magento-install-dir>
Install the current version of the Magento Community Database (replace and change placeholders <xxx> to your needs)
# create the magento database tables
bin/magento setup:install \
--admin-firstname Admin \
--admin-lastname Developer \
--admin-email <my@emailadress.com> \
--admin-user admin \
--admin-password admin123 \
--base-url <https://projecthostname.test>/ \
--db-host <host-ip-address>:<database-port> \
--db-name <my-local-magento-instance> \
--db-user root --db-password root --use-rewrites 1 \
--backend-frontname admin \
--currency EUR --timezone Europe/Berlin \
--cleanup-database

Step 4: 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

Step 5: 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