04/09/2014 at 8:34 am
#288126
Keymaster
@ Mark
I do know what you are asking. Actually, there is no way to specifiy which “Other” to import into. They’ll import into the first one the database finds. Honestly, this is not a scenario that was taking into account when importing. It is possible but there would have to be code changes to allow this.
Open the class.entry-import-csv.php file found here:
../wp-content/plugins/connections-csv/includes/class.entry-import-csv.php
Change this block of code from:
foreach ( $categories as $category ) {
$category = $format->sanitizeString( $category );
if ( array_key_exists( $category, $this->cache['category'] ) ) {
// If the term has already been queried use the cached copy rather than query the db again.
$term = $this->cache['category'][ $category ];
} else {
// Query the db for the term to be added.
$term = $instance->term->getTermBy( 'name', $category, 'category' );
// If the term was found store it in the cache for reuse.
if ( $term != FALSE ) $this->cache['category'][ $category ] = $term;
}
if ( $term != FALSE && $term->name == $category ) {
$termIDs[] = $term->term_id;
} else {
// Add the new category.
$instance->term->addTerm( $category, 'category', array( 'slug' => '', 'parent' => '0', 'description' => '' ) );
// addTerm should be refactored to return the insert ID so the getTermBy query does not need done.
// Get the newly added term object.
$term = $instance->term->getTermBy('name', $category, 'category');
$termIDs[] = $term->term_id;
}
}
to this:
foreach ( $categories as $category ) {
$category = $format->sanitizeString( $category );
if ( array_key_exists( $category, $this->cache['category'] ) ) {
// If the term has already been queried use the cached copy rather than query the db again.
$term = $this->cache['category'][ $category ];
} else {
// Query the db for the term to be added.
$term = $instance->term->getTermBy( 'slug', $category, 'category' );
// If the term was found store it in the cache for reuse.
if ( $term != FALSE ) $this->cache['category'][ $category ] = $term;
}
if ( $term != FALSE && $term->slug == $category ) {
$termIDs[] = $term->term_id;
} else {
// Add the new category.
$instance->term->addTerm( $category, 'category', array( 'slug' => '', 'parent' => '0', 'description' => '' ) );
// addTerm should be refactored to return the insert ID so the getTermBy query does not need done.
// Get the newly added term object.
$term = $instance->term->getTermBy('slug', $category, 'category');
$termIDs[] = $term->term_id;
}
}
Now, in you CSV file instead of using the category name, you would use the category slug.
Hope that helps!
