• Resolved sejkan

    (@sejkan)


    Hi Dear,
    Is there possible to get Category name under import.
    I want to print imported /or existing category name under costum field or attribute.

    Do you have some quick function to do this.

    function my_woocommerce_print_category_name() {
            $cat = $product->get_categories();
        echo $cat; ?>    
    }

    Thank you

    • This topic was modified 5 years, 9 months ago by sejkan.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @sejkan

    You can use the pmxi_saved_post hook along with the wc_get_product_category_list() function for this.

    Example:

    add_action( 'pmxi_saved_post', 'my_put_categories_in_custom_field', 10, 3 );
    
    function my_put_categories_in_custom_field( $id, $xml, $update ) {
    	$category_list = wc_get_product_category_list( $id );
    	update_post_meta( $id, 'my_category_list', $category_list );
    }
    Thread Starter sejkan

    (@sejkan)

    Hi Dear,
    How to implement this function cros wp all import.
    What I want is to create new attribute caled Categories, and then put new or existing category there.

    This is good solution because original woocommerce layered navigation dont support category filter.

    Thank you a lot,
    Sejkan

    Plugin Author WP All Import

    (@wpallimport)

    Hi @sejkan

    I’d suggest importing a pipe delimited list of the categories inside the “Attributes” tab of the WooCommerce Add-On – this way you can avoid custom code.

    If you’d rather do it by programmatically retrieving all of the categories and adding them as attribute terms, you could, but it’s not something we could help code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Print Category name’ is closed to new replies.