/** * importCategory * * @param array $category * @param NodeInterface $startingPointCategories * @param NodeInterface $startingPointProducts * @param Context $context * @return NodeInterface */ private function importCategory(array $category, NodeInterface $startingPointCategories, NodeInterface $startingPointProducts, Context $context) { $nodeTemplate = new NodeTemplate(); $nodeTemplate->setNodeType($this->nodeTypeManager->getNodeType('Egobude.Products:Category')); $nodeTemplate->setProperty('title', $category['title']); $randomProducts = $this->getRandomProducts($context, $startingPointProducts); if (!empty($randomProducts)) { $nodeTemplate->setProperty('products', $randomProducts); } $categoryNode = $startingPointCategories->createNodeFromTemplate($nodeTemplate); if (!empty($category['description'])) { $body = $category['description']; $mainContentNode = $categoryNode->getNode('main'); $bodyTemplate = new NodeTemplate(); $bodyTemplate->setNodeType($this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Text')); $bodyTemplate->setProperty('text', $body); $mainContentNode->createNodeFromTemplate($bodyTemplate); } return $categoryNode; }