affixing a parent category when importing xml into woocommerce

Question

I configure import according to this manual.Categories are imported without hierarchy, all at the same level. What needs to be corrected in the code so that the hierarchy is taken into account when importing?

function my_get_category( $id ) {
$term = get_terms( array(
        'taxonomy' => 'product_cat',
        'hide_empty' => false,
        'meta_query' => array(
            array(
                'key'       => '_category_id',
                'value'     => $id,
                'compare'   => '='
            )
        )
    )
);
if ( ! empty( $term ) ) {
    return $term[0]->slug;
}       
}

I suppose that this can somehow be implemented through get_ancestors () or get_term_meta ()
but there is no understanding how to do this. please help

0
Lexx633 2 years 2020-12-30T06:10:24-05:00 0 Answers 4 views 0

Leave an answer

Browse
Browse