• Resolved dkutcher

    (@dkutcher)


    Looking for any assistance to add the date a product was first published to the standard product export function within woocommerce. Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi @dkutcher

    Natively, as you noticed, the published date isn’t exported to the CSV file.

    If you are comfortable with coding, you’ll need to programmatically add a new column, then assign the published date field to that column.

    Alternatively, you can use a plugin like the WP all export. There’re a few other plugins that grant you a more customizable way to handle your export/import products.

    Let us know how it goes!

    My very best,

    Any solution to the problem? Looking to export all products including the published date.

    I also needed to export the slugs which was able to export with

    add_filter( 'woocommerce_product_export_column_names', 'add_slug_export_column' );
    add_filter( 'woocommerce_product_export_product_default_columns', 'add_slug_export_column' );
    
    function add_slug_export_column( $columns ) {
    	$columns['slug'] = 'Slug';
     
    	return $columns;
    }

    Is there anything similar for published date?

    Hi @tabrizi

    I understand that you want to show the published date when exporting products on your site.

    These forums are meant for general support with the core functionality of WooCommerce itself. What you want to achieve would require customization to do it. Since custom coding is outside our scope of support, I am leaving this thread open for a bit to see if anyone can chime in to help you out.

    For questions related to development and custom coding, your best bet is to ask on any of these channels for support. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.

    WooCommerce Developer Resources Portal
    WooCommerce Advanced Facebook group
    WooCommerce Community Forum
    WooCommerce Developer Slack Channel.
    – Hire a WooCommerce Expert

    Hope this helps!

    Dustin

    (@dustinparkerwebdev)

    Adding the following filters to your child theme’s functions.php file or a custom plugin should do the trick:

    
    // Add our custom columns to the existing columns
    add_filter( 'woocommerce_product_export_product_default_columns', function ( $columns ) {
    
    	// The key/id "published_date" is what we will use in the next filter to define the column's value
    	$columns['published_date'] = __( 'Published Date', 'woocommerce' );
    
    	return $columns;
    }, 11 );
    
    // Return the desired value for the "published_date" column
    add_filter( 'woocommerce_product_export_product_column_published_date', function ( $value, $product, $column_id ) {
    
    	return $product->get_date_created()->date( 'Y/m/d' );
    }, 11, 3 );

    Hey Dustin, this works great. Thank you very much! But I can not import the products again with the published date :/

    Dustin

    (@dustinparkerwebdev)

    @tabrizi to allow importing that field, you’d need to add the following filters:

    
    // Add our custom fields to the formatting callbacks array
    add_filter( 'woocommerce_product_importer_formatting_callbacks', function ( $callbacks, $importer ) {
    
    	$callbacks['date_created'] = array( $importer, 'parse_date_field' );
    
    	return $callbacks;
    }, 11, 2 );
    
    // Add our custom fields to the default mapping columns
    add_filter( 'woocommerce_csv_product_import_mapping_default_columns', function ( $columns, $raw_headers ) {
    
    	$columns[ __( 'Published Date', 'woocommerce' ) ] = 'date_created';
    
    	return $columns;
    }, 11, 2 );
    
    // Add our custom fields to the mapping options dropdown
    add_filter( 'woocommerce_csv_product_import_mapping_options', function ( $options, $item ) {
    
    	$options['date_created'] = __( 'Published Date', 'woocommerce' );
    
    	return $options;
    }, 11, 2 );

    You may want to change the date format on the export to something like Y-m-d h:s:i so that on import you set the time of day that it was published, not just 12:00am on that date.

    Thank you so much! You are the best. If you ever need a oriental rug, feel free to look on our website and contact us, I will gladly fix you the best price possible!

    https://www.tabrizi-shop.de

    This code is just amazing, thank you, save me the day.

    My 2 cents is unfortunately that I found a small issue, it gets stuck without exporting if you try to export a product that is in DRAFT status.

    Big thanks

    Hello, @dustinparkerwebdev. I have a similar problem with the hook woocommerce_product_importer_formatting_callbacks. I need, when I import a csv, to implement a custom function to the field category_ids instead of the function “parse_categories_field”. So I think to change the callback function associate to this field. How to do this?

    Thanks

    Roxy

    (@roxannestoltz)

    Hi @ethan978 ,

    To align with?forum best practices, please create a new topic so that we can address your issue/request separately.

    You can create a new thread here.

    Thanks for understanding!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Add published date column to woocommerce product export?’ is closed to new replies.