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>isproduct-import-inventory-msi, the<FILENAME>is a combination of date and time like20190608-114344, and the<COUNTER>is a incremental number with two digits starting with01 -
As a result, the filename is look like
product-import-inventory-msi_20190608-114344_01.csv -
Additionally the appropriate
.okfile is needed
|
The CSV file with the Magento 2 CE/EE attributes consists of the following columns:
| Column Name | Type | Example | Description |
|---|---|---|---|
sku |
|
|
The product SKU to import the inventory source item for |
source_code |
|
|
The code for the source of the products. |
status |
|
|
The stock status of the product for this source. |
quantity |
|
|
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 |
|
The inventory import step must be called with the command |
|
The default file name is |
|
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.bunchwith the observerimport_product_msi.observer.inventory.source.item.updatefor the add-update and the observerimport_product_msi.observer.clear.inventory.source.itemandimport_product_msi.observer.inventory.source.itemfor the replace operation -
The observer
import_product_msi.observer.product.source.itemthat has to be added after the first observer of the firstimport_product.subject.bunch subject -
The observers
import_product_msi.observer.product.source.itemandimport_product.observer.composite.base.deletebefore theimport_product.observer.composite.base.deleteof the subjectimport_product.subject.bunchof the delete operation -
The subject
import_product_msi.subject.bunchwith the observerimport_product_msi.observer.clear.inventory.source.itemof 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"
]
}
]
}
]
}
...,
]
}
]
}