As explained in our blog post Product Status Update Only, there may be situations you want or can use M2IF as framework. This blog post gives you an idea of a declarative approach to break down the general product import functionality down to update the link types only without any coding.

Please keep in mind, that with this very simple configuration, only the link types will be updated. The updated_at date of the product entity itself will NOT be refreshed. If this is o. k. for you, have fun :-)

Step 1: Configuration

Create a configuration snippet <magento-install-dir>/app/etc/configuration/operations.json with the content

{
  "operations": {
    "ce": {
      "catalog_product": {
        "links": {
          "plugins": {
            "subject": {
              "id": "import.plugin.subject",
              "subjects": [
                {
                  "id": "import_product.subject.bunch",
                  "file-resolver": {
                    "prefix": "product-import"
                  },
                  "params": {
                    "clean-up-empty-columns": [
                    ]
                  },
                  "observers": [
                    {
                      "import": [
                        "import_product.observer.last.entity.id",
                        "import_product_link.observer.product.link",
                        "import_product.observer.clean.up"
                      ]
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    }
  }
}

Additionally, we need to create a second configuration snippet <magento-install-dir>/app/etc/configuration/shortcuts.json with the content

{
  "shortcuts": {
    "ce": {
      "catalog_product": {
        "links": [
          "general/general/global-data",
          "general/general/move-files",
          "general/catalog_product/collect-data",
          "ce/catalog_product/links",
          "ce/catalog_product/add-update.links"
        ]
      }
    }
  }
}

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 link types. This makes thinks very easy, as the CSV file MUST have at least two columns, namely sku and <link-type>_skus. The file, for example, will then look like this

sku related_skus
24-MB01 24-MB05,24-MB03,24-MB04
24-MB04 24-MB05,24-MB03,24-MB02
24-MB03 24-MB05,24-MB01,24-MB04

Step 3: Execute the command

Finally, copy the CSV file(s),with the structure above to the directory <magento-install-dir>/var/importexport and execute the command which updates the link types

<magento-install-dir>/bin/import-cli-simple.phar import:create:ok-file \
   && <magento-install-dir>/bin/import-cli-simple.phar import:products links

Done!

Previous Post

Load Comments

Please note that by clicking "Load Comments", your browser will establish a connection with servers from Disqus.
For more information, please visit our privacy statement.