Clean-up

Pacemaker Community Edition provides a clean-up function that removes values for empty columns or relations that are no longer part of the CSV file.

Deleting data can significantly impact performance; the clean-up function should get used with caution.

It is recommended to use the add-update operation since it is generally only added or updated if it is already present

Cleanup Flags

Images

clean-up-empty-image-columns

Clean-up images

Media gallery

clean-up-media-gallery

Clean-up media gallery

Category Product relations

clean-up-category-product-relations

Clean-up category product relations

Website Product relations

clean-up-website-product-relations

Clean-up website Product relations

Tier Prices

clean-up-tier-prices

Clean-up tier prices

URL Rewrites

clean-up-url-rewrites

Clean-up URL rewrites

Clean-up empty columns

clean-up-empty-columns

Product variant

clean-up-variant

Clean-up product variant

Product Links

clean-up-links

Clean-up product links

It is helpful to delete images that are no longer included in the CSV files from the database most of the time.

The Image type, e.g., is stored in different tables:
  • Thumbnail as an attribute

  • Links to the product

  • As well as name and position

Example

To clean-up both, it is necessary to set the flags to the default value 'true':
{
    "operations" : {
      "ce" : {
        "catalog_product" : {
          "add-update" : {
            "plugins" : {
              "subject" : {
                "id" : "import.plugin.subject" ,
                "subjects" : [
                  {
                    "id" : "import_product_ee.subject.bunch" ,
                    "file-resolver" : {
                      "prefix" : "product-import"
                    } ,
                    "params" : {
                      "copy-images" : false ,
                      "media-directory" : "pub/media/catalog/product" ,
                      "images-file-directory" : "var/importexport/media/catalog/product" ,
                      "clean-up-media-gallery" : true , (1)
                      "clean-up-empty-image-columns" : true , (2)
                    },
                    "observers" : [
                      {
                        "import" : [
                          "import_product_ee.observer.composite.base.add_update"
                        ]
                      }
                    ]
                  }
                ]
              }
            }
          }
        }
      }
    }
}
1 To set the clean-up-media-gallery flag to true or false
2 To set the clean-up-empty-image-columns flag to true or false
  • The flags are true by default

If you are unsure what to do, both flags should have the same value.

Category Product relations

In many cases, the product category relationships do not change infrequently.

Suppose the product category relationships change frequently, and it is necessary to update them with the add-update operation.

Example

That can get performed by setting the clean-up-category-product-relations flag to true:
{
  "operations" : {
    "ce":{
      "catalog_product": {
        "add-update": {
          "plugins": {
            "subject": {
              "id": "import.plugin.subject",
              "subjects": [
                {
                  "id": "import_product_ee.subject.bunch",
                  "file-resolver": {
                    "prefix": "product-import"
                  },
                  "params": {
                    "copy-images" : false ,
                    "media-directory" : "pub/media/catalog/product" ,
                    "images-file-directory" : "var/importexport/media/catalog/product" ,
                    "update-url-key-from-name" : true ,
                    "clean-up-category-product-relations" : true ,(1)
                  }
                  "observers": [
                    {
                      "import": ["import_product_ee.observer.composite.base.add_update"]
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    }
  }
}
1 To set the clean-up-category-product-relations flag to true or false.
  • true is set by default

Since the product-category relation gets not persist to only one column, this relation cannot be cleaned-up by adding a column name to the clean-up-empty-columns array.

Website Product relations

Suppose the product-website relationships change frequently, and it becomes necessary to update them with the add-update operation.

Example

In that case, it can get achieved by setting the clean-up-website-product-relations flag to true:
{
  "operations" : {
    "ce":{
      "catalog_product": {
        "add-update": {
          "plugins": {
            "subject": {
              "id": "import.plugin.subject",
              "subjects": [
                {
                  "id": "import_product_ee.subject.bunch",
                  "file-resolver": {
                    "prefix": "product-import"
                  },
                  "params": {
                    "copy-images": false,
                    "media-directory" : "pub/media/catalog/product",
                    "images-file-directory" : "var/importexport/media/catalog/product",
                    "update-url-key-from-name": true,
                    "clean-up-website-product-relations": true,(1)
                  "observers": [
                    {
                      "import": [
                        "import_product_ee.observer.composite.base.add_update"
                      ]
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    }
  }
}
1 To set website-relations flag to true or false
  • true is set by default

Since the product-website-relationship gets not persist to only one column, that relationship cannot be cleaned up by adding a column name to the clean-up-empty-columns array

Tier prices

Prices nearly always need to be up-to-date, so if tier prices are imported, the clean-up functionality should be activated by setting the flag clean-up-tier-prices to true.

Example

{
  "operations": {
    "catalog_product": {
      "add-update.tier-prices": {
        "plugins": {
          "subject": {
            "id": "import.plugin.subject",
            "listeners": [
              {
                "plugin.process.success": [
                  "import_product_tier_price.listener.delete.obsolete.tier_prices"
                ]
              }
            ],
            "params": {
              "clean-up-tier-prices": true,(1)
            },
            "subjects": [
              {
                "id": "import_product_tier_price.subject.tier_price",
                "listeners": [
                  {
                    "subject.import.success": [
                      "import_product.listener.register.sku.to.pk.mapping"
                    ]
                  }
                ],
                "file-resolver": {
                  "prefix": "tier-price"
                },
                "observers": [
                  {
                    "import": [
                      "import_product_tier_price.observer.tier_price.update"
                    ]
                  }
                ]
              }
            ]
          }
        }
      }
    }
  }
}
1 To set clean-up-tier-prices flag to true or false
  • true is set by default

Url rewrite

Since the category/product functionality in Magento is more basic, the clean-up only provides a flag for the URL rewrites.

Example Category url rewrite

As with the category import, the flags must get configured at the subject level, e.g.:
{
  "operations": {
    "ce": {
      "catalog_category": {
        "add-update.url-rewrite": {
          "plugins": {
            "subject": {
              "id": "import.plugin.subject",
              "subjects": [ (1)
                {
                  "id": "import_category.subject.bunch",
                  "file-resolver": {
                    "prefix": "category-url-rewrite"
                  },
                  "params": {
                    "clean-up-url-rewrites": "false" (2)
                  },
                  "observers": [
                    {
                      "import": [
                        "import_category.observer.url.rewrite.update"
                      ]
                    }
                  ]
                }
              ]
            }
          }
        }
      }
    }
  }
}
1 Subject level
2 To set Url rewrites flag to true or false
  • true is set by default

Example Product url rewrite

As with the product import, the flags must get configured at the subject level, e.g.:
{
    "operations": {
        "ce" : {
            "catalog_product" : {
                "add-update.url-rewrites": {
                    "plugins": {
                        "subject": { (1)
                            "id": "import.plugin.subject",
                            "subjects": [
                                {
1 Subject level

Clean-up empty columns

Comma seperated ( , ) array list to define empty values for product attributes and additional attributes

Be aware that the columns specified in additional_attributes must be cleaned and contain empty values, e.g. if the following columns columns activity and in_recommends need to get cleaned, the column additional_attributes must contain the value "activity=,erin_recommends=" as a valid format.

Valid empty column format examples:
  • ["<column>="]

  • ["<column1>=,<column2>="]

Example

To enable the clean-up functionality for product attributes and additional attributes, the columns to get cleaned up must get specified in the clean-up-empty-columns array:
...
  "params": {
    ...,
    "clean-up-empty-columns": ["activity", "erin_recommends"]
  },
...

Product Variants

  • In Magento 2, a product variant refers to a specific variation or option of a configurable product

  • A configurable product is a parent product that represents a set of related products with different attributes, such as size, color, or material

  • Each unique combination of attributes represents a variant of the configurable product.

  • To delete this relation set the clean-up-variants flag to true

Example

{
    "operations": {
        "catalog_product": {
            "add-update": {
                "plugins": {
                    "subject": {
                        "id": "import.plugin.subject",
                        "subjects": [
                            {
                                "id": "import_product_ee.subject.bunch",
                                "file-resolver": {
                                    "prefix": "product-import"
                                },
                                "params": {
                                    "copy-images": false,
                                    "media-directory" : "pub/media/catalog/product",
                                    "images-file-directory" : "var/importexport/media/catalog/product",
                                    "update-url-key-from-name": true,
                                    "clean-up-variants": false,(1)
                                }
                                "observers": [
                                    {
                                        "import": ["import_product_ee.observer.composite.base.add_update"]
                                    }
                                ]
                            }
                        ]
                    }
                }
            }
        }
    }
}
1 To set the clean-up variants flag to true or false, false is set by default

In Magento 2, product links refer to the associations or relationships between different products within the system. These links allow you to establish connections between products based on various criteria. Magento 2 provides several types of product links that serve different purposes

  • To delete this relation set the clean-up-links flag to true

Example

{
    "operations": {
        "catalog_product": {
            "add-update": {
                "plugins": {
                    "subject": {
                        "id": "import.plugin.subject",
                        "subjects": [
                            {
                                "id": "import_product_ee.subject.bunch",
                                "file-resolver": {
                                    "prefix": "product-import"
                                },
                                "params": {
                                    "copy-images": false,
                                    "media-directory" : "pub/media/catalog/product",
                                    "images-file-directory" : "var/importexport/media/catalog/product",
                                    "update-url-key-from-name": true,
                                    "clean-up-links": false,(1)
                                }
                                "observers": [
                                    {
                                        "import": ["import_product_ee.observer.composite.base.add_update"]
                                    }
                                ]
                            }
                        ]
                    }
                }
            }
        }
    }
}
1 To set the clean-up links flag to true or false, false is set by default

Disable clean-up

Example

To disable the clean-up function, override the operations file and set the clean-up-* flags to false in <custom-configuration-dir>/operations.json: