Step 1: Konfiguration Test
We're starting with a minimized configuration file that has the following content
{
"magento-edition": "CE",
"magento-version": "2.3.4",
"operation-name" : "add-update",
"archive-artefacts" : true,
"debug-mode" : false,
"entity-type-code" : "catalog_product",
"listeners" : [
{
"app.set.up" : [
"import.listener.render.ansi.art",
"import.listener.initialize.registry"
]
},
{
"app.tear.down" : [
"import.listener.clear.registry"
]
}
],
"databases" : [
],
"loggers": [
{
"name": "system",
"channel-name": "logger/system",
"type": "Monolog\\Logger",
"handlers": [
{
"type": "Monolog\\Handler\\ErrorLogHandler",
"formatter": {
"type": "Monolog\\Formatter\\LineFormatter",
"params" : [
{
"format": "[%datetime%] %channel%.%level_name%: %message% %context% %extra%",
"date-format": "Y-m-d H:i:s",
"allow-inline-line-breaks": true,
"ignore-empty-context-and-extra": true
}
]
}
}
],
"processors": [
{
"type": "Monolog\\Processor\\MemoryPeakUsageProcessor"
}
]
}
],
"operations" : [
{
"name" : "add-update",
"plugins" : [
{
"id": "import.plugin.global.data"
},
{
"id": "import.plugin.subject",
"subjects": [
{
"id": "import.subject.move.files",
"identifier": "move-files",
"file-resolver": {
"prefix": "product-import"
},
"ok-file-needed": true
},
{
"id": "import_product.subject.bunch",
"identifier": "files",
"file-resolver": {
"prefix": "product-import"
},
"observers": [
{
"import": [
"import_product.observer.last.entity.id",
"import_product.observer.product.attribute.update",
"import_product.observer.clean.up"
]
}
]
}
]
},
{
"id": "import.plugin.archive"
}
]
}
]
}
The configuration contains only the add-update operation, which is the only operation that makes sense, as we only want to change the status of an existing product. Therefore we can simply copy the configuration file of the default product import, remove the other operations and replace the observers of the import_product.subject.bunch with the observers
- import_product.observer.last.entity.id
- import_product.observer.product.attribute.update
- import_product.observer.clean.up
That's pretty all that has to be done on the configuration side.
Step 2. CSV Structure
In the second step, we've a look at the structure of the CSV file that contains the product status data. As explained at the start of the post, we only want to update the product status. This makes thinks very easy, as the CSV file only has two columns, namely sku and product_online. The file, for example, will then look like this
sku | product_online |
---|---|
24-MB01 | 1 |
24-MB04 | 2 |
24-MB03 | 2 |
Step 3. Command
Finally you've to invoke the command that starts the status update. Assuming that you're in the , the configuration file is available under <magento-installation-dir>/app/etc/configuration/techdivision-import.json and the CSV file has been stored in <magento-installation-dir>/var/importexport/product-import_20200317-215123_01.csv, the command will be
bin/import-cli-simple.phar import:create:ok-file \
&& bin/import-cli-simple.phar import:products \
--configuration=app/etc/configuration/techdivision-import.json
Done!