Title: lbov's Replies | WordPress.org

---

# lbov

  [  ](https://wordpress.org/support/users/lbov/)

 *   [Profile](https://wordpress.org/support/users/lbov/)
 *   [Topics Started](https://wordpress.org/support/users/lbov/topics/)
 *   [Replies Created](https://wordpress.org/support/users/lbov/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/lbov/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/lbov/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/lbov/engagements/)
 *   [Favorites](https://wordpress.org/support/users/lbov/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Tainacan] Bulk creation of collections](https://wordpress.org/support/topic/bulk-creation-of-collections/)
 *  Thread Starter [lbov](https://wordpress.org/support/users/lbov/)
 * (@lbov)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/bulk-creation-of-collections/#post-14032643)
 * Hello, I created 300 empty collections to import items in each one with CSV files,
   but for some reason after collections are created tainacan starts to run too 
   slow, mainly when I try to open a collection for editing it and item list and
   filters take a lot of time to load, even if there is no items at all in the repository.
   I can’t find why?
 * I did another test, I created another wordpress instance with tainacan and created
   a single collection, then I imported 1700 items with its respective pdf (special
   document) to this collections. In this case, I have not experimented slow speed
   problems.
 * So, I think it is something related with the collections creation process I’m
   doing, maybe I’m doing something wrong.
 * For collection creation I run the following code with wp-cli:
    wp eval-file test.
   php –user=1
 * Its a wrong way to do it? I really appreciate any hint you could give me.
 * code of test.php:
 *     ```
       <?php
   
       namespace Tainacan\Importer;
       use \Tainacan\Entities;
   
       class Test_Collections extends Importer {
   
       	public function __construct($attributes = array()) {
       			parent::__construct($attributes);
   
       			$this->tax_repo = \Tainacan\Repositories\Taxonomies::get_instance();
       			$this->col_repo = \Tainacan\Repositories\Collections::get_instance();
       			$this->items_repo = \Tainacan\Repositories\Items::get_instance();
       			$this->metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
       			$this->item_metadata_repo = \Tainacan\Repositories\Item_Metadata::get_instance();
   
       			$this->remove_import_method('file');
       			$this->remove_import_method('url');
       	}
   
       	public function bulk_collectionss() {
       		for ($c = 1; $c <= 300; $c++) {
       			$collection = new \Tainacan\Entities\Collection();
       			$collection->set_name("col-name-" . $c);
       			$collection->set_status("publish");
   
       			if ($collection->validate()) {
       				$collection = $this->col_repo->insert($collection);
       				echo "Success: " . $collection->get_id() . "\n";
       			} else {
       				$errors = $collection->get_errors();
       				echo "Error on:" . $collection->get_id() . "\n" . $errors;
       				exit();
       			}
   
       			$col_map = [];
       			$core_title = $collection->get_core_title_metadatum();
       			$core_description = $collection->get_core_description_metadatum();			
       			$col_map[$core_title->get_id()] = 'field1';
       			$col_map[$core_description->get_id()] = 'field12';					
   
       			$this->add_collection([
       					'id' => $collection->get_id(),
       					'mapping' => $col_map,
       					'total_items' => 0,
       					'source_id' => 'col' . $c
       			]);
       		}
       	}
   
   
       	public function process_item($index, $collection_definition) {
       		$method = 'get_' . $collection_definition['source_id'] . '_item';
       		$item = $this->$method($index);
       		return $item;
       	}
   
   
       }
   
       // TEST
   
       $bc = new Test_Collections();
       $bc->bulk_collectionss();
       ```
   
    -  This reply was modified 5 years, 6 months ago by [lbov](https://wordpress.org/support/users/lbov/).
    -  This reply was modified 5 years, 6 months ago by [lbov](https://wordpress.org/support/users/lbov/).
    -  This reply was modified 5 years, 6 months ago by [lbov](https://wordpress.org/support/users/lbov/).
    -  This reply was modified 5 years, 6 months ago by [lbov](https://wordpress.org/support/users/lbov/).
    -  This reply was modified 5 years, 6 months ago by [lbov](https://wordpress.org/support/users/lbov/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Tainacan] Bulk creation of collections](https://wordpress.org/support/topic/bulk-creation-of-collections/)
 *  Thread Starter [lbov](https://wordpress.org/support/users/lbov/)
 * (@lbov)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/bulk-creation-of-collections/#post-13569806)
 * Thanks vnmedeiros!, what I’m looking for is a way to create many collections 
   at once. I’m a little confused because the automatic-creation-of-metadata talks
   about categories and taxonomies, Categories and collections are the same?
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)