Step 1: Download and Install a blank Magento 2 instance
You'll find the Magento 2 sources on the Magento website. The best way will be to download the complete package directly from the Magento website. Assuming, that you'll have a running system, follow the instructions from the Magento instructions to install your Magento 2 instance.
Step 2: Preparation of the Magento 2 instance
When you've a running Magento 2 instance with Sample Data, you additionally need to download the sample CSV import files from the repository techdivision/import-cli-simple. Add this repository, as well as the repository with the sample data to your Magento installation by invoking
cd <magento-install-dir> \ && composer require techdivision/import-cli-simple \ && composer require techdivision/import-sample-data
The Pacemaker Community CLI well as the Sample Data files for your Magento 2 version should now be available under the <magento-install-dir>/vendor/bin/techdivision/import-cli-simple and <magento-install-dir>/vendor/bin/techdivision/import-sample-data directories.
Additionally, the product images can be linked in the Magento media directory. As by default the images are NOT copied to the media directory, they can be linked to make them visible in the frontend after importing the products. This can be done by
cd <magento-install-dir> \ && ln -s <magento-install-dir>/techdivision/import-sample-data/generic/media/catalog/product \ <magento-install-dir>/pub/media/catalog/product
Step 3: Explaining Bunches
Pacemaker is able to handle bunches. In general this is a functionality that will only make sense in a multithreaded or multiprocessed environment where the bunches can be imported in parallel. In this case, it should only give the developer an idea, on how a multiprocessed functionality can be implemented.
A bunch is a CSV file which is only a part of a complete import. It doesn't matter, what a kind of data a bunch contains, as the importer handles the data in the necessary order. This means, that the first step is to import all simple products found in a bunch. After that, information like the created entity IDs related with the imported SKUs, which is necessary to import all other product data (bunches, configurables, images, related etc.) will be shared, so it'll be possible to import these data step-by-step, but each step also in parallel.
To split a import into multiple bunches, the bunched files MUST follow these pattern:
- The prefix has to equal, e. g. product-import
- The prefix has to be followed by an underscore (_)
- A random number of alphanumeric characters has to follow
- These characters has also to be followed by an underscore (_)
- Finally, each bunch MUST have a sequential number, followed by .csv
For example, the following CSV files that contains the product sample data will be imported as a bunch:
When starting the import process by invoking the appropriate command, these files will be imported like one file. It is NOT necessary to invoke the importer four times.
Step 4: Running the Import
When this is the first import, what we're assuming here, default import directory <magento-install-dir>/var/importexport has to be created and all the files with the sample data (attribute-sets, attributes, categories and products) have to be copied to this directory. The command to import the sample data including the images, looks like this
sudo mkdir var/importexport \ && 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 \ && 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:categoies && vendor/bin/import-simple import:products
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
which results in one of
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/importexport/product-import_20161021-161909.ok for example and contains the following lines
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.