MSI

Pacemaker Community Edition (CE) provides a dedicated MSI import and the appropriate command import:products:inventory:msi therefore.

You can find more information about how to invoke the command in the usage section.

  • The filename for the dedicated MSI import must match the pattern <PREFIX>_<FILENAME>_<COUNTER>.csv

  • The default <PREFIX> is product-import-inventory-msi, the <FILENAME> is a combination of date and time like 20190608-114344, and the <COUNTER> is a incremental number with two digits starting with 01

  • As a result, the filename is look like product-import-inventory-msi_20190608-114344_01.csv

  • Additionally the appropriate .ok file is needed

  • There is a fixed structure for the bunch import, which must be followed.

  • The three parts to be specified are each separated by an underscore ( _ ) and result in a filename like <PREFIX>_<FILENAME>_<COUNTER>.csv.

  • The name structure follows a predefined filename structure that is mandatory for the Bunch import.

The CSV file with the Magento 2 CE/EE attributes consists of the following columns:

Column Name Type Example Description

sku

varchar

24-MB01

The product SKU to import the inventory source item for

source_code

varchar

default

The code for the source of the products.

status

integer

1

The stock status of the product for this source.

quantity

decimal

98.0

The amount of the product for this source.

Use cases

Import without MSI:

  • CSV requires the following columns: sku, qty, is_in_stock

  • Inventory Import Step must be called with the command import:products:inventory

  • The default file name is: product-import-inventory_<xx>.csv

If MSI should be imported with the full product import, read the appropriate xref:[documentation] how this can be archived.

Import with MSI:

CSV requires the following columns

sku, quantity, status, source_code

The inventory import step must be called with the command

import:products:inventory:msi

The default file name is

product-import-inventory-msi_<xx>.csv

To use MSI with the default product import, two steps are necessary.

Step 1: Add Additional Column

Add the column inventory_source_items also to import MSI stock data with the product import.

For example, the column must contain the data in the following structure, e. g.

source_code=default,quantity=10.0,status=1|source_code=inventory-01,quantity=5.0,status=1

As for the tier prices, the column with the MSI inventory source items supports the same format. Our sample data comes with an example of how the file should look.

Step 2: Extend Configuration

The second step is to add the subject that processes the MSI to your configuration file.

An example configuration file for the Pacemaker Community Edition (CE) is part of the Pacemaker Community Edition (CE) command-line tool.

The configuration for the appropriate operations has to be extended with

  • The subject import_product_msi.subject.bunch with the observer import_product_msi.observer.inventory.source.item.update for the add-update and the observer import_product_msi.observer.clear.inventory.source.item and import_product_msi.observer.inventory.source.item for the replace operation

  • The observer import_product_msi.observer.product.source.item that has to be added after the first observer of the first import_product.subject.bunch subject

  • The observers import_product_msi.observer.product.source.item and import_product.observer.composite.base.delete before the import_product.observer.composite.base.delete of the subject import_product.subject.bunch of the delete operation

  • The subject import_product_msi.subject.bunch with the observer import_product_msi.observer.clear.inventory.source.item of the delete operation

For the delete operation, the configuration has to look like following code

{
 ...,
 "operations": [
   {
      "name" : "delete",
      "plugins" : [,
        {
          "id": "import.plugin.subject",
          "subjects": [
            ...,
            {
              "id": "import_product.subject.bunch",
              ...,
              "observers": [
                {
                  "import": [
                    "import_product.observer.last.entity.id",
                    "import_product_msi.observer.product.source.item",
                    "import_product.observer.composite.base.delete"
                  ]
                }
              ]
            },
			...,
            {
              "id": "import_product_msi.subject.bunch",
              "identifier": "files",
              "file-resolver": {
                "prefix": "inventory-msi"
              },
              "observers": [
                {
                  "import": [
                    "import_product_msi.observer.clear.inventory.source.item"
                  ]
                }
              ]
            }
          ]
        }
        ...,
      ]
    }
  ]
}

For the replace operation, the configuration has to look like

{
  ...,
  "operations": [
       {
      "name" : "replace",
      "plugins" : [
        ...,
        {
          "id": "import.plugin.subject",
          "subjects": [
            {
              "id": "import_product.subject.bunch",
    	      ...,
              "observers": [
                {
                  "import": [
                    "import_product.observer.composite.base.replace",
                    "import_product_msi.observer.product.source.item"
                  ]
                }
              ]
            },
            ...,
            {
              "id": "import_product_msi.subject.bunch",
              "identifier": "files",
              "file-resolver": {
                "prefix": "inventory-msi"
              },
              "observers": [
                {
                  "import": [
                    "import_product_msi.observer.clear.inventory.source.item",
                    "import_product_msi.observer.inventory.source.item"
                  ]
                }
              ]
            }
          ]
        }
        ...,
      ]
    }
  ]
}

For the add-update operation, the configuration has to look like

{
 ...,
 "operations": [
   {
      "name" : "add-update",
      "plugins" : [,
        {
          "id": "import.plugin.subject",
          "subjects": [
            ...,
            {
              "id": "import_product.subject.bunch",
              ...,
              "observers": [
                {
                  "import": [
                    "import_product.observer.composite.base.add_update",
                    "import_product_msi.observer.product.source.item"
                  ]
                }
              ]
            },
			...,
            {
              "id": "import_product_msi.subject.bunch",
              "identifier": "files",
              "file-resolver": {
                "prefix": "inventory-msi"
              },
              "observers": [
                {
                  "import": [
                    "import_product_msi.observer.inventory.source.item.update"
                  ]
                }
              ]
            }
          ]
        }
        ...,
      ]
    }
  ]
}