MSI with default product import

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

Step 1: Add additional Column

Add the inventory_source_items column to be able to import MSI inventory data as well with the product import.

As for the tier prices, the column with the MSI inventory source items supports the same format.

Example

source_code=default,quantity=10.0,status=1|source_code=inventory-01,quantity=5.0,status=1 (1)
1 The field inventory_source_items must contain the data in the given structure. Every line is seperated by a pipe ( | )

Step 2: Extend Configuration

Add the subject that processes the MSI to your configuration file

The configuration for the appropriate operations has to get extended /changed as follows

The best strategy to extend/customize the configuration file operations.json is either:

  • create a custom Magento module including all modifications

  • Create a copy of operations.json under app/etc/configuration/operations.json, remove unnecessary default lines/sections, and insert the needed customizations in the new operations.json

delete operation

For the delete operation, the configuration has to be structured as the following code
{
  "operations": {
    "general": {
      "catalog_product_inventory_msi": {
        "delete": { (1)
          "plugins" : [
            {
              "id": "import.plugin.subject", (2)
              "subjects": [
                ...,
                {
                  "id": "import_product.subject.bunch", (3)
                  ...,
                  "observers": [
                    {
                      "import": [
                        "import_product.observer.last.entity.id", (4)
                        "import_product_msi.observer.product.source.item", (5)
                        "import_product.observer.composite.base.delete" (6)
                      ]
                    }
                  ]
                },
                ...,
                {
                  "id": "import_product_msi.subject.bunch", (7)
                  "identifier": "files", (8)
                  "file-resolver": {
                    "prefix": "inventory-msi" (9)
                  },
                  "observers": [
                    {
                      "import": [
                        "import_product_msi.observer.clear.inventory.source.item" (10)
                      ]
                    }
                  ]
                }
              ]
            }
            ...,
          ]
        },
1 Find delete section
2 Find id: import.plugin.subject section
3 Find id: import_product_msi.subject.bunch section
4 Add the observer import_product.observer.last.entity.id to import
5 Add the observer import_product_msi.observer.product.source.item to import
6 Add the observer import_product.observer.composite.base.delete to import
7 Find next id: import_product_msi.subject.bunch section
8 Add/find identifier: files
9 Update file-resolver.prefix value to inventory-msi. This can be any name for the generated file prefix.
10 Add the observer import_product_msi.observer.clear.inventory.source.item to import

replace operation

For the replace operation, the configuration has to be structured as following code
        "replace": { (1)
          "plugins" : [
            {
              "id": "import.plugin.subject", (2)
              "subjects": [
                {
                  "id": "import_product.subject.bunch", (3)
                  ...,
                  "observers": [
                    {
                      "import": [
                        "import_product.observer.composite.base.replace", (4)
                        "import_product_msi.observer.product.source.item" (5)
                      ]
                    }
                  ]
                },
                ...,
                {
                  "id": "import_product_msi.subject.bunch", (6)
                  "identifier": "files", (7)
                  "file-resolver": {
                    "prefix": "inventory-msi" (8)
                  },
                  "observers": [
                    {
                      "import": [
                        "import_product_msi.observer.clear.inventory.source.item", (9)
                        "import_product_msi.observer.inventory.source.item" (10)
                      ]
                    }
                  ]
                }
              ]
            }
            ...,
          ]
        },
1 Find replace section
2 Find id: import.plugin.subject section
3 Find id: import_product_msi.subject.bunch section
4 Add the observer import_product.observer.composite.base.replace to import
5 Add the observer import_product_msi.observer.product.source.item to import
6 Find next id: import_product_msi.subject.bunch section
7 Add/find identifier: files
8 Update file-resolver.prefix value to inventory-msi. This can be any name for the generated file prefix.
9 Add the observer import_product_msi.observer.clear.inventory.source.item to import
10 Add the observer import_product_msi.observer.inventory.source.item to import

add-update operation

For the add-update operation, the configuration has to be structured as following code
        "add-update": { (1)
          "plugins" : [
            {
              "id": "import.plugin.subject", (2)
              "subjects": [
                ...,
                {
                  "id": "import_product.subject.bunch", (3)
                  ...,
                  "observers": [
                    {
                      "import": [
                        "import_product.observer.composite.base.add_update", (4)
                        "import_product_msi.observer.product.source.item" (5)
                      ]
                    }
                  ]
                },
                ...,
                {
                  "id": "import_product_msi.subject.bunch", (6)
                  "identifier": "files", (7)
                  "file-resolver": {
                    "prefix": "inventory-msi" (8)
                  },
                  "observers": [
                    {
                      "import": [
                        "import_product_msi.observer.inventory.source.item.update" (9)
                      ]
                    }
                  ]
                }
              ]
            }
            ...,
          ]
        },
      }
    }
  }
}
1 Find add-update section
2 Find id: import.plugin.subject section
3 Find id: import_product_msi.subject.bunch section
4 Add the observer import_product.observer.composite.base.update to import
5 Add the observer import_product_msi.observer.product.source.item to import
6 Find next id: import_product_msi.subject.bunch section
7 Add/find identifier: files
8 Update file-resolver.prefix value to inventory-msi. This can be any name for the generated file prefix.
9 Add the observer import_product_msi.observer.inventory.source.item.update to import