Tier prices

Tier price import only

Pacemaker Community Edition (CE) provides a dedicated tier price import and the appropriate command import:products:price:tier therefore.

You can find more information about how to invoke the command in the usage section.

  • The filename for the dedicated tier price import must match the pattern <PREFIX>_<FILENAME>_<COUNTER>.csv.

  • The default <PREFIX> is product-import-tier-price, the <FILENAME> is a combination of date and time like 20190608-114344, and the <COUNTER> is a incremental number with two digits starting with 01.

  • As a result, the filename is look like product-import-tier price_20190608-114344_01.csv.

  • Additionally, the appropriate .ok file is needed.

  • There is a fixed structure for the bunch import, which must be followed.

  • The three parts to be specified are each separated by an underscore ( _ ) and result in a filename like <PREFIX>_<FILENAME>_<COUNTER>.csv.

  • The name structure follows a predefined filename structure that is mandatory for the Bunch import.

The CSV file with the attributes for the Magento 2 CE/EE consists of the following columns:

Column Name Type Example Description

sku

varchar

24-MB01

The product SKU to import the tier price for the required Product

tier_price_website

varchar

All Websites

The website code to import the tier price for

  • All Websites as default for all websites or

  • <website_code>

tier_price_customer_group

varchar

ALL GROUPS

The customer group for which the tiered price get imported, or 'ALL GROUPS' for all customer groups

tier_price_qty

decimal

20.0

The quantity the tier price is valid from

tier_price

decimal

98.0

The tier price itself

tier_price_value_type

varchar

Fixed

The value type can either be

  • Fixed|Discount

If the tier prices are imported with the full product import, read the description below.

Multi Websites/Stores import of products including tier prices

To perform a successful multi websites/stores product import, the field tier_prices must be added to the product import data CSV with the data field structure description as followed

  • Admin row:

    • Add additional column

      • The first step is to add the column tier_prices to the CSV file with the product data.

      • When importing tier_prices to multiple store views, the tier_prices field must be populated with the following given format and separated by a pipe (|)

    • No list element escaping required

    • Example store view 1: qty=5,price=51.000000,value_type=fixed,website=All Websites,customer_group=ALL GROUPS

    • Example store view 2: qty=15,price=3.00,value_type=fixed,website=additional_base,customer_group=General

    • Example store view 3: qty=10,price=47.750000,value_type=discount,website=base,customer_group=ALL GROUPS

Example tier_prices field result. The data sets are seperated by pipes (|)
qty=5,price=51.000000,value_type=fixed,website=All Websites,customer_group=ALL GROUPS|qty=15,price=3.00,value_type=fixed,website=additional_base,customer_group=General|qty=10,price=47.750000,value_type=discount,website=base,customer_group=ALL GROUPS
  • There is no limitation in how many rows of tier prices the column contains. THe pipe (|) will separate each row with tier prices, whereas each column of a row including the attribute_code to value pairs will be separated by the common comma (,).

  • The attribute_code to value pairs itself will use the = char for separation.

  • Our sample data comes with an example of how the file should look.

Table 1. Field tier_prices value structure
Attribute Example Description

qty

5

The number entered determines when a tier_price takes effect

price

51.000000

The value entered under price takes effect when the min. count specified under qty is reached or greater

value_type

fixed

The value type is defind by a choice of 2 Values

* [fixed|discount]

website

All Websites

The website value is defind by the unique Website Code [website_code]. The Value All Websites is predefined by Magento.

ce file structure tier prices
Figure 1. Magento Backend > Stores > All Stores ⇒ add the Web Site Code to the attribute website=additional_base

customer_group

ALL GROUPS

The Customer Group defines the associated User Group

* [ALL GROUPS|General|Retailer|NOT LOGGED IN|Wholesale]

  • The actual website_code for each additional store view, the store view code is entered at the argument website=<WEBSITE CODE>

  • No entry in store_view_code field

  • Store row

    • In the field store_view_code for each additional store view, except the admin row, the field must be filled with the respective store view code (default,de_de, en_us,…​)

    • No entry in the field tier_prices is required for the following store code related additional product values

if you want to track the import more carefully in the directory importexport, feel free to use following additional params to import products

  • --archive-artefacts=false --clear-artefacts=false

ce file structure tier prices product
Figure 2. Add the Store View Code to the field store_view_code in your import CSV file (Example: de_de, en_us, …​..)
vendor/bin/import-simple import:products --archive-artefacts=false --clear-artefacts=false

the additional arguments make sure that the imported files and logs are not removed after a import. You will find all processed files after a import in a newly created folder named as timestamp

ce file structure tier prices artifact
Figure 3. Using the parameters --archive-artefacts=false --clear-artefacts=false a new directory will be created with the current timestamp as folder name
ce file structure tier prices csv1
Figure 4. Add the Store View Code to the field store_view_code in your import CSV file (Example: de_de, en_us, …​..)
ce file structure tier prices csv2
Figure 5. Add the Multi-Store Attributes to the field tier_prices as described in the admin row

For testing purpose only:

If you want to check the result of a multi-store product import in the Magento backend, please make sure in advance that the following default options are set:

  • Stores  Configuration  Catalog /Catalog  Price [Catalog Price Scope ⇒ Website]

  • Stores  Configuration  General  Web  Url Options [Add Store Code to Urls ⇒ Yes]

Extend Configuration

The second step is to add the listener, the subjects, and the observers that process the tier prices 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_tier_price.subject.tier_price with the observer import_product_tier_price.observer.tier_price.update for the add-update and the observer import_product_tier_price.observer.tier_price for the replace operation

  • The observer import_product_tier_price.observer.product.tier_price has to be added after the first observer of the first import_product.subject.bunch subject

  • A listener import_product_tier_price.listener.delete.obsolete.tier_prices for the event plugin.process.success on subject level (only for add-update operation)

  • Param clean-up-tier-prices on the subject level either with the value true or false, which decides whether or not tier-prices should be cleaned-up (only for add-update operation)

If the clean-up functionality is activated with the param clean-up-tier-prices set to true, all tier prices that are not anymore part of the SKUs in the CSV file will be removed.

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_tier_price.observer.product.tier_price"
                  ]
                }
              ]
            },
            ...,
            {
              "id": "import_product_tier_price.subject.tier_price",
              "identifier": "files",
              "file-resolver": {
                "prefix": "tier-price"
              },
              "observers": [
                {
                  "import": [
                    "import_product_tier_price.observer.tier_price"
                  ]
                }
              ]
            }
          ]
        }
        ...,
      ]
    }
  ]
}

For the add-update operation, the configuration has to look like

{
 ...,
 "operations": [
   {
      "name" : "add-update",
      "plugins" : [,
        {
          "id": "import.plugin.subject",
          "listeners" : [
             {
              "plugin.process.success" : [
                "import_product_tier_price.listener.delete.obsolete.tier_prices"
              ]
            }
          ],
          "params" : [
            {
              "clean-up-tier-prices" : true
            }
          ],
          "subjects": [
            ...,
            {
              "id": "import_product.subject.bunch",
              ...,
              "observers": [
                {
                  "import": [
                    "import_product.observer.composite.base.add_update",
                    "import_product_tier_price.observer.product.tier_price"
                  ]
                }
              ]
            },
			...,
            {
              "id": "import_product_tier_price.subject.tier_price",
              "file-resolver": {
                "prefix": "tier-price"
              },
              "observers": [
                {
                  "import": [
                    "import_product_tier_price.observer.tier_price.update"
                  ]
                }
              ]
            }
          ]
        }
        ...,
      ]
    }
  ]

For both operations, it has to be be addeded after the import_product_url_rewrite.subject.url.rewrite. The delete operation configuration does not need any customizations as the tier prices will be cleaned up by their foreign keys.