Import/Export cookbook: How to import product prices for Magento 2 Shared Catalogs
Shared Catalogs allow Magento 2 Commerce owners to create product categories for particular companies (Magento 2 B2B feature) with the individual prices, which are not available for general customers. In this article we will use Improved Import & Export extension to import and export prices for the Shared Catalogs.
Shared Catalogs feature the same exact products which are available in your product catalog, however the prices for such products may be adjusted for B2B company customer accounts. Now, how can you import these product prices inside your Magento 2? In this cookbook article I will explain that it is nothing new, and you already know how to do it, and have probably done it many times.
Table of contents
To import product prices for Shared Catalogs, we first need to understand what are Magento 2 Commerce Shared Catalogs.
The Shared Catalogs functionality for Magento 2 Commerce is only available with B2B extension, which enables such B2B features as company accounts, shared catalogs, content scheduling, and other.
Shared Catalogs are your basic product categories, which can be assigned to Companies of your customers, so that each company member can access the assigned shared product catalog.
When you create a Shared Catalog, you select the product category and the products inside it. Then, you can adjust the prices of the products in this category which will only be available for company members. Other customers, which do not belong to the company will be displayed with the regular product prices.
When the Shared Catalog is saved, Magento 2 creates a new customer group which is assigned to the created Shared Catalog. All the companies which you have assigned to the Shared Catalog also change their customer group to that of the catalog, and can purchase products inside the catalog at the individual prices.
The custom prices which you create for the companies, are stored inside Magento as the Tier Prices (Advanced Pricing) – the basic product setting which can be applied to ANY product. Advanced Pricing can be found inside the product details screen, under the Price field of the product.
This brings us to the conclusion: to import prices for the Shared Catalogs – you need to import ‘Advanced Pricing’ entity. Below I will show you how.
Get Improved Import & Export extension for Magento 2
First option – using Advanced Pricing files
If you want to skip the export part, you can get the sample file with the Advanced Pricing in the
Step 1: create an export job
Navigate to System > Improved Import / Export > Export Jobs and click the ‘Add New Job’ button.
Step 2: configure export job
You do not need to fill each job setting, fill only the fields I specify below, to quickly export product catalog:
- Job Title – name the job
- Entity – select ‘Advanced Pricing’
- Export Source – select ‘File’
- File path – specify the path where to export the file. E.g. copy and paste: /var/import/shared_catalog_pricing.csv
Intermedia
You can end it here and get your full Magento 2 product catalog exported. However, you can use filters and export only required products, and only attributes you are going to update
Step 3: export and get the price list
Hit the ‘Save & Run’ button in the upper-right corner of the screen to get the products exported.
You will get a file with the products’ advanced pricing, which are ready for the update.
I have got myself a CSV file which looks like this and that I have opened with Google Sheets:
Editing advanced prices
The best place to edit CSV files is the Google Sheets. I cannot stress enough how easy and fast it is. Especially when you can have several managers from your team working on a single document that you share with few clicks.
Edit the file with your team the way you need.
Attribute name | Reference | Values | Value example |
sku | SKU is the first field of the table and canNOT be removed.
For every instance of Tier Price you need to specify a separate product line. Meaning that if product has two tier prices these will be imported in two lines |
Can be up to 64 characters in length.
It must be a unique value for every product. It is used to identify the product and is the only mandatory field. You can find SKUs for products already in the catalog at Catalog > Products. Mind the letter case! |
TST-Conf-Simp-S-Gray |
tier_price_website | Defines the websites where the tier price is available.
If specifying multiple websites, separate each with a comma and without a space |
Website code can be found under Stores > All Stores > next, click required website and find “Code” field. | base |
tier_price_customer_group | Defines customer groups for which the tier prices are available | When typing in customer groups mind the case.
If specifying multiple groups, separate each with a comma and without a space. ALL GROUPS – if the tier price should be applied to all customer groups |
Customer Group 1,Customer Group 2 |
tier_price_qty | The quantity of the product that must be ordered to receive tier price | Can be any numeral value | 5 |
tier_price | The Price value for particular amount of the products added to the cart | Can be any numeral value | 10 |
tier_price_value_type | The type of the discount applied when customer adds particular number of items to the cart | Fixed – product price becomes fixed value specified in the tier_price column
Discount – product price is discounted by the percent value specified in the tier_price column |
Discount |
You can also adjust your files to look like these, when you need to update the prices for your shared catalogs.
Do not convert the Google Sheets back to CSV. With Improved Import & Export you can paste the link to the Google Sheet table, and import it to the store.
Step 1: create an import job
Navigate to System > Improved Import / Export > Import Jobs and click the ‘Add New Job’ button.
Step 2: configure import job
You do not need to fill each job setting, fill only the fields I specify below, to quickly import product updates to your Magento 2 store:
- Job Title – name the job
- Entity – select ‘Advanced Pricing’
- Import Behavior – select ‘Add/Update’
- Import file type – select CSV file type
- Import Source – select ‘Google Sheets’
- URL – paste URL of the Google Sheet where you have edited product price and quantity
Step 3: validate file and import
Inside the Import Source section click the ‘Validate file’ button, and click the ‘Save & Run’ button at the upper-right corner of the screen. Then ‘Run’ again.
Step 4: check the result
Now that the import job is complete you can proceed to Catalog > Products and check the updates prices and quantity.
This option relies on customization we have made with the Improved Import & Export extension for Magento 2.
The customization allows exporting and importing ‘Products’ entity along with the ‘Advanced Pricing’ in a single file. By default Magento 2 considers Advanced Pricing separate entity, however with Improved Import & Export, you can import products directly with Advanced Pricing.
To do this, you can export your product catalog as described above, or add a custom column to the file where you store the products. The custom column should be named tier_prices and will look like this, where the values inside the column go like this:
Customer Group,Product qty,Discounted price,Discount percent,Website|Another tier
Where:
- Customer Group – is the name of the customer group the tier price will be applied to. Mind the letter case when typing customer group name.
- Product qty – product quantity customer has to add to the cart to be a subject for the tier price.
- Discounted price – fixed price of the product that will be applied once customer adds to the cart required quantity of the product.
- Discount percent – a discount that will be applied to the product price once customer adds to the cart required quantity of the product.
- Website – the code of the website the tier price is applied to. You can find the code of the website at Stores > All Stores > Click required website in the grid > Copy the value in ‘code’ field. Use ‘All’ to apply to All Websites.
Use comma to separate tier price attributes and pipe to separate multiple tier prices.
NOTE:
You can only use either a Discounted price or Discount percent.
- If you want to use Discounted price – set Discount percent value to ‘0’;
- If you want to use Discount percent – set Discounted price value to ‘0.
Read more about this custom solution in the dedicated article on Advanced Pricing in Magento 2.
Get Improved Import & Export extension for Magento 2
This is it, now you can import and export product prices for the Shared Catalogs you have with your Magento 2.