How to duplicate woocommerce product attribute to custom field?

Going to each product page to duplicate the attribute to a custom field can be time consuming. There are more efficient ways to accomplish this task. You can use any of the following options to speed up the process:

  • Best option: Get the ‘WCPT Addon: Copy Attribute to Meta’ plugin that can help you automatically copy all attributes to product meta with one click. Sold separately from WCPT PRO.
  • Use the in-built WooCommerce Import / Export facility to modify products in an excel sheet.
  • Use a bulk product editor plugin.

Note: Before following the steps in this guide, please take a database backup first!

WCPT Addon: Copy Attribute to Meta

This is the simplest and fastest way to:

(1) Copy attributes to meta for all your woocommerce products with just one click.
(2) Automatically keep the attributes and meta in sync in the future, with no additional effort.

You can set up this plugin once and forget about it. It will automatically manage copying attributes to meta as your website data changes going ahead, ie, attribute values change or new products are created.

While the next 2 options will also help you copy over attributes to custom fields, you will need to repeat the process of copying attributes to meta each time you make changes to your product attributes.

On the other hand, ‘WCPT Addon: Copy Attribute to Meta’ can copy attributes to meta automatically whenever you make any changes to your products in the future.

This addon plugin is sold separately from WCPT PRO. To get the addon contact support.

WooCommerce import / export products facility

You can read the official woocommerce documentation on this topic here. It covers how to use this woocommerce facility. The following guide further explains how to achieve the specific aim of copying over attributes to meta as per our requirement.

  • Begin by exporting the products as a CSV file. This file can be viewed as a spreadsheet via Excel (Windows) or Numbers (Mac).
  • In that exported CSV file, products are listed in rows and their properties are listed in column. You need to create a new column that will contain a new custom field for the products. This new column needs to have the heading ‘Meta: *attribute name*’ where your need to replace *attribute name* with the name of the actual attribute (Color, Size, etc) or custom field name that you want to use. Before continuing with this step, please refer to the ‘Important notes on creating the new meta column’ section below.

  • After you have added the new meta field column to the file, you need to save the file as CSV. Now import this modified csv file into your site again. During import, ensure you check the option to ‘Update existing products’. After the import process (could take some time depending on the number of products and properties) you should have the new custom field prepared for each product based on the mtea column you created in the import file.

Important note on creating the new meta column:

In the exported excel file please notice 2 things:

  • Attribute information is split over multiple columns: Name, Values, Visible, Global, Default. Only the Name and Values column are relevant to us here, so we will ignore the rest. The Name column helps us identify which attribute(s) this column pertains to and the values are needed to be copied over to the new duplicate meta column.
  • Second thing to notice – in the above screenshot Attribute 1 name column only contains the Color attribute. So you might be tempted to simply duplicate its values column, rename the heading of the duplicate to Meta: Color and be done with the process. While this may work in this particular case, please keep in mind that the attribute columns in your export file might contains information about multiple attributes in the same column.
  • For example, in the screenshot below notice that the ‘Attribute 2 name’ column contains 2 distinct attributes – Size and Logo. So, in this case, duplicating the ‘Attribute 2 value(s)’ column to create a new meta column for Size attribute will be a mistake. As you can imagine, such a duplicate column will also contains values for Logo attribute. So, you will need to be careful that only relevant values are copied over to the new meta column.
  • In this example, to create a meta column for the Size attribute, we can duplicate the values column, but then we need to carefully go over the column values in our duplicate and delete the values that are not related to Size.

If you have any confusion about this method and need more clarity please do not hesitate to write into support to receive prompt assistance with this.

Bulk product editor plugins

This method is slower than the import/export method described above but some users might find this more convenient as it is simpler.

The following woocommerce bulk product editor plugins will allow you to edit multiple products at one time using a simple UI:

The above links are for the free versions of the plugin. Some features are only available in the PRO version.