Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 0.7.9.5, category, csv import, Name, slug
- This topic has 1 reply, 2 voices, and was last updated 9 years, 8 months ago by
Steven Zahm.
-
AuthorPosts
-
04/09/2014 at 4:42 am #288120
Mark Wiseman
ParticipantI have multiple categories setup with sub categories.
Some of theses sub categories are named the same ie. I have mulitple instances of “Other” as a sub category.
How do I specify which sub category of “Other” to user in the import?
Hopefully that makes sense!
Thanks
04/09/2014 at 8:34 am #288126Steven Zahm
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!
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.