Skip to content

Commit daa45e0

Browse files
committed
removing product_cat hierarchy to prevent duplicates
1 parent c51106e commit daa45e0

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

includes/Generator/Generator.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,18 @@ protected static function generate_term_ids( $limit, $taxonomy, $name = '' ) {
7979
$terms = array_merge( self::$faker->words( $limit ), array( strtolower( $words[0] ) ) );
8080
}
8181

82-
$args = array( 'parent' => 0 );
83-
8482
foreach ( $terms as $term ) {
85-
if ( isset( self::$term_ids[ $taxonomy ][ $args['parent'] ], self::$term_ids[ $taxonomy ][ $args['parent'] ][ $term ] ) ) {
86-
$term_id = self::$term_ids[ $taxonomy ][ $args['parent'] ][ $term ];
83+
if ( isset( self::$term_ids[ $taxonomy ], self::$term_ids[ $taxonomy ][ $term ] ) ) {
84+
$term_id = self::$term_ids[ $taxonomy ][ $term ];
8785
$term_ids[] = $term_id;
8886

89-
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
90-
$args['parent'] = $term_id;
91-
}
92-
9387
continue;
9488
}
9589

9690
$term_id = 0;
9791
$args = array(
9892
'taxonomy' => $taxonomy,
9993
'name' => $term,
100-
'parent' => $args['parent'],
10194
);
10295

10396
$existing = get_terms( $args );
@@ -113,13 +106,8 @@ protected static function generate_term_ids( $limit, $taxonomy, $name = '' ) {
113106
}
114107

115108
if ( $term_id ) {
116-
117-
$term_ids[] = $term_id;
118-
self::$term_ids[ $taxonomy ][ $args['parent'] ][ $term ] = $term_id;
119-
120-
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
121-
$args['parent'] = $term_id;
122-
}
109+
$term_ids[] = $term_id;
110+
self::$term_ids[ $taxonomy ][ $term ] = $term_id;
123111
}
124112
}
125113

0 commit comments

Comments
 (0)