• Resolved nenosw

    (@nenosw)


    Hi there,

    I added mapping for custom product taxonomies to the import tool according to these instructions:
    https://github.com/woocommerce/woocommerce/wiki/Product-CSV-Importer-&-Exporter#adding-custom-import-columns-developers

    When I import my csv the extra columns are shown and automatically mapped to the right fields. But after finishing the import, the new products are added but the custom taxonomies are empty.

    Any ideas what could be the problem? thanks

    /**
     * Register the 'Marke' column in the importer.
     *
     * @param array $options
     * @return array $options
     */
    function add_column_to_importer( $options ) {
    
    	// column slug => column name
    	$options['marke'] = 'Marke';
    
    	return $options;
    }
    add_filter( 'woocommerce_csv_product_import_mapping_options', 'add_column_to_importer' );
    
    /**
     * Add automatic mapping support for 'Custom Column'. 
     * This will automatically select the correct mapping for columns named 'Custom Column' or 'custom column'.
     *
     * @param array $columns
     * @return array $columns
     */
    function add_column_to_mapping_screen( $columns ) {
    	
    	// potential column name => column slug
    	$columns['Marke'] = 'marke';
    	$columns['marke'] = 'marke';
    
    	return $columns;
    }
    add_filter( 'woocommerce_csv_product_import_mapping_default_columns', 'add_column_to_mapping_screen' );
    
    /**
     * Process the data read from the CSV file.
     * This just saves the value in meta data, but you can do anything you want here with the data.
     *
     * @param WC_Product $object - Product being imported or updated.
     * @param array $data - CSV data read for the product.
     * @return WC_Product $object
     */
    function process_import( $object, $data ) {
    	
    	if ( ! empty( $data['marke'] ) ) {
    		$object->update_meta_data( 'marke', $data['marke'] );
    	}
    
    	return $object;
    }
    add_filter( 'woocommerce_product_import_pre_insert_product_object', 'process_import', 10, 2 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nenosw

    (@nenosw)

    Well I managed to do a successful import with the WP All Import plugin, but I am still curious about why the ‘woocommerce way’ doesnt work.

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Where you able to locate the custom places to add the data and did that information match exactly? Also, have you tried exporting the data after adding the snippet?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Import of Custom Taxonomy fails’ is closed to new replies.