Create collection

@param array $data Collection data

@return \Magento\Catalog\Model\ResourceModel\Category\Collection
@throws \Magento\Framework\Exception\LocalizedException
321048
public function create(array $data = [])
    {
        $collection = parent::create($data);

        if ($this->getCurrentCategory() && $this->getCurrentCategory()->getLevel() >= 2) {
            $collection->addAttributeToFilter('entity_id', ['neq' => (int) $this->getCurrentCategory()->getId()]);

            $rootPath      = array_slice($this->getCurrentCategory()->getPathIds(), 0, 2);
            $pathCondition = implode('/', $rootPath) . '%';
            $collection->addFieldToFilter('path', ['like' => $pathCondition]);
        }

        return $collection;
    }
874732
public function createCollectorForSurvey($surveyId, array $data = [])
	{
		return $this->sendRequest(
			$this->createRequest('POST', sprintf('surveys/%s/collectors', $surveyId), [], $data)
		);
	}
78724
private function createItems(Collection $collection, array $collectionItemsData): void
    {
        foreach ($collectionItemsData as $collectionItemData) {
            $itemDefinition = $this->itemDefinitionRegistry->getItemDefinition($collectionItemData['value_type']);

            $item = $this->cmsItemLoader->loadByRemoteId(
                $collectionItemData['value'],
                $collectionItemData['value_type']
            );

            $itemCreateStruct = $this->collectionService->newItemCreateStruct(
                $itemDefinition,
                $item->getValue()
            );

            $this->setConfigStructs(
                $itemCreateStruct,
                $itemDefinition,
                $collectionItemData['configuration'] ?? []
            );

            $this->collectionService->addItem($collection, $itemCreateStruct, $collectionItemData['position']);
        }
    }
1180202
public function create(array $data = [])
    {
        $lists = new Lists();

        if (array_key_exists('items', $data)) {
            $lists->setItems(
                $this->getListItemFactory()->createCollection($data['items'])
            );
        }

        /** Images */
        if (array_key_exists('poster_path', $data)) {
            $lists->setPosterImage($this->getImageFactory()->createFromPath($data['poster_path'], 'poster_path'));
        }

        return $this->hydrate($lists, $data);
    }
257947
public function merge($data) : Collection
    {
        return static::create(array_merge($this->data, $this->convertToArray($data)));
    }
1262931
public function create(array $data) {
        $data[$this->foreignKey] = $this->parent->{$this->localKey};
        return call_user_func(sprintf('%s::create', $this->query->getModelName()), $data);
    }
1180040
public function fromDbTableRows(Collection $data)
    {
        $iterator = new \ArrayIterator();
        foreach ($data as $item) {
            $iterator->append($this->fromDbTableRow($item));
        }

        return $iterator;
    }
55344
public function createResultCollection($data = [], $method = 'create')
    {
        $collection = new ResultCollection();

        if (null === $data) {
            return $collection;
        }

        if (array_key_exists('page', $data)) {
            $collection->setPage($data['page']);
        }

        if (array_key_exists('total_pages', $data)) {
            $collection->setTotalPages($data['total_pages']);
        }

        if (array_key_exists('total_results', $data)) {
            $collection->setTotalResults($data['total_results']);
        }

        if (array_key_exists('results', $data)) {
            $data = $data['results'];
        }

        foreach ($data as $item) {
            $collection->add(null, $this->$method($item));
        }

        return $collection;
    }
845427
public function create(array $data) : Model
    {
        $model_class = $this->getModelName();
        return $this->postCreate($data, $model_class::create($this->preCreate($this->parseData($data))));
    }
1355015
private function createCollection(DocumentManager $documentManager, ClassMetadata $classMetadata, $collectionName)
    {

        $database = $documentManager->getDatabase();

        $exists = false;
        foreach ($database->listCollections() as $collection) {
            if ($collection->getName() == $collectionName) {
                $exists = true;
            }
        }

        $creationOptions = $classMetadata->getCollectionCreationOptions();
        if (!empty($creationOptions) && !$exists) {
            $database->createCollection($collectionName, $creationOptions);
        }

        $collectionOptions = $classMetadata->getCollectionOptions();

        return $database->selectCollection($collectionName, $collectionOptions);
    }
795540
public function create($data)
    {
        $collection = new DescriptorCollection();

        foreach ($data as $type) {
            $collection->add($this->createDescriptorForType($type));
        }

        return $collection;
    }
766205
public function createCollection($className)
    {
        $className = (string) $className;
        if (array_key_exists($className, $this->aliases)) {
            $className = $this->aliases[$className];
        }

        return $this->getCollectionManager()->create($className);
    }
1280634
public function create($data)
    {
        $descriptor = new MethodDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $descriptor->setMethodName($data->getMethodName());

        $response = new ReturnDescriptor('return');
        $response->setTypes($this->builder->buildDescriptor(new Collection($data->getTypes())));
        $descriptor->setResponse($response);

        foreach ($data->getArguments() as $argument) {
            $argumentDescriptor = $this->createArgumentDescriptorForMagicMethod($argument);
            $descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
        }

        return $descriptor;
    }
1094280
protected function createGenericCollectionFromMediaTypes($data = [])
    {
        $movieFactory = new MovieFactory($this->getHttpClient());
        $tvFactory    = new TvFactory($this->getHttpClient());
        $collection   = new GenericCollection();

        foreach ($data as $item) {
            switch ($item['media_type']) {
                case "movie":
                    $collection->add(null, $movieFactory->create($item));
                    break;

                case "tv":
                    $collection->add(null, $tvFactory->create($item));
                    break;

                default:
                    throw new \RuntimeException('Unknown media type "%s"', $item['media_type']);
            }
        }

        return $collection;
    }
370419
public function create(array $data = [])
    {
        $engine = $this->scopeConfig->getValue($this->configPath, ScopeInterface::SCOPE_STORE);

        $fullActionClass = $this->fullActionPool['default'];

        if (isset($this->fullActionPool[$engine])) {
            $fullActionClass = $this->fullActionPool[$engine];
        }

        return $this->objectManager->create($fullActionClass, ['data' => $data]);
    }
749342
public function toCollection($data): ICollection
	{
		if ($data instanceof QueryBuilder) {
			return new DbalCollection($this, $this->connection, $data);

		} elseif (is_array($data)) {
			$storageReflection = $this->getStorageReflection();
			$result = array_map([$this->getRepository(), 'hydrateEntity'], array_map([$storageReflection, 'convertStorageToEntity'], $data));
			return new ArrayCollection($result, $this->getRepository());

		} elseif ($data instanceof Result) {
			$result = [];
			$repository = $this->getRepository();
			$storageReflection = $this->getStorageReflection();
			foreach ($data as $row) {
				$result[] = $repository->hydrateEntity($storageReflection->convertStorageToEntity($row->toArray()));
			}
			return new ArrayCollection($result, $this->getRepository());
		}

		throw new InvalidArgumentException('DbalMapper can convert only array|QueryBuilder|Result to ICollection.');
	}
1049096
public function create(array $data){
        $model = $this->model->create($data);
        //check for hasMany
        if($this->validateRelationData($this->withHasMany,'many')){
            $model->{$this->withHasMany['relation']}()->saveMany($this->withHasMany['data']);
        }
        //check for belongsToMany
        if($this->validateRelationData($this->withBelongsToMany,'tomany')){
            $model->{$this->withBelongsToMany['relation']}()->sync($this->withBelongsToMany['data']);
        }
        return $model;
    }