• Resolved Andrew Comb

    (@tecazwebdev)


    Ok I’m not sure what version it appeared in, but WooCommerce now has a ‘GTIN, UPC, EAN, or ISBN’ field, which was sorely missed, as a lot of modern shops require it, such as Google shopping. I’ve tested it, and it saves the info, however I cannot for the life of me work out where it is saved, and how I could use it:

    I have other plugins for WooCommerce which already have added this as Meta: fields inside the product, which at present is how I read / write manufacturers EAN numbers into products, via bulk updates, and write it to the site, via functions, but exporting the csv, the new field just doesn’t show up?

    Is this an oversight, bug, or intentional? Surely it should be in the standard export, and not in the custom meta fields, but currently it’s nowhere I can see, without diving into mysql, which is a bit above my head!

Viewing 8 replies - 16 through 23 (of 23 total)
  • Use the codes so that the column appears in the product export and export in CSV.

    add_filter('woocommerce_product_export_columns', 'add_ean_to_export_columns');
    function add_ean_to_export_columns($columns) {
    // Add a new column to the CSV for the _global_unique_id field
    $columns['ean_gtin_mpn'] = 'EAN/GTIN/MPN';
    return $columns;
    }

    add_filter('woocommerce_product_export_product_default_columns', 'add_ean_to_default_export_columns');
    function add_ean_to_default_export_columns($columns) {
    // Add the column to the default set of exported columns
    $columns['ean_gtin_mpn'] = 'EAN/GTIN/MPN';
    return $columns;
    }

    add_filter('woocommerce_product_export_product_column_ean_gtin_mpn', 'export_ean_meta_data', 10, 2);
    function export_ean_meta_data($value, $product) {
    // Retrieve the value of the custom field _global_unique_id
    return $product->get_meta('_global_unique_id', true);
    }

    // Add EAN to Import
    add_filter('woocommerce_csv_product_import_mapping_options', 'add_ean_to_import_mapping_options');
    function add_ean_to_import_mapping_options($options) {
    // Add EAN/GTIN/MPN to the list of mapping options during import
    $options['ean_gtin_mpn'] = 'EAN/GTIN/MPN';
    return $options;
    }

    add_filter('woocommerce_csv_product_import_mapping_default_columns', 'map_ean_column_to_meta_key');
    function map_ean_column_to_meta_key($columns) {
    // Map the EAN/GTIN/MPN column to the _global_unique_id meta key
    $columns['EAN/GTIN/MPN'] = '_global_unique_id';
    $columns['ean_gtin_mpn'] = '_global_unique_id';
    return $columns;
    }

    add_action('woocommerce_product_import_inserted_product_object', 'import_ean_meta_data', 10, 2);
    function import_ean_meta_data($product, $data) {
    // Save the value from the EAN/GTIN/MPN column to the _global_unique_id meta key
    if (!empty($data['ean_gtin_mpn'])) {
    $product->update_meta_data('_global_unique_id', $data['ean_gtin_mpn']);
    }
    }
    • This reply was modified 2 months, 3 weeks ago by julianosb.

    @julianosb nice!! I’ll give this a try. Woocommerce also forgot to add the GTIN field in the Quick Edit menu on the products page in Admin as well.

    @joyryde They said that in version 9.5 it will be fixed and you won’t need the snippets anymore.

    So, did the snippets work for you?

    • This reply was modified 2 months, 3 weeks ago by julianosb.

    Yup! The snippets work (at least I can see the field in the export menu, I haven’t exported using it yet). I did get the github update today saying it’s going to be officially released in 9.5. Nobody has responded to me about how they didn’t add it to the Quck Edit menu yet though.

    Plugin Support Feten L. a11n

    (@fetenlakhal)

    Hi there @joyryde

    The team answered your request 3 hours ago: https://github.com/woocommerce/woocommerce/issues/51600#issuecomment-2540803115

    Also, since Andrew started the thread, please open a new thread if you need any help or want to discuss any issues.

    I’ll go ahead and resolve this one.

    Have a nice day!

    Fix – Adds the missing global_unique_id field to the product import mapper #52240
    Fix – Adds the missing global_unique_id to the product export columns #51703

    Fingers crossed! Hopefully it will be out today

    Thread Starter Andrew Comb

    (@tecazwebdev)

    Julianosb: I tried the code snippet. The export worked great, The import didn’t work. Hopefully they “real “official” fix works.

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!
    Thank you for testing and sharing your feedback!

    I’m happy to let you know that we’ve fixed this issue in WooCommerce version 9.5.0, which will be released soon. We appreciate your patience and cooperation while we worked on this.

Viewing 8 replies - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.