/** * @return void */ public function indexAction() { $pages = $this->pageRepository->findPagesContainingRecordType('tx_cadabra_domain_model_product'); $products = $this->productRepository->findAll(); $this->view->assign('products', $products); $this->view->assign('pages', $pages); }
/** * Generate articles from an array of hashes * * @param array $hashes * @param boolean $persist * @return \SplObjectStorage */ public function generateArticlesFromHashes($hashes, $persist = false) { $articles = new \SplObjectStorage(); foreach ($hashes as $hash) { $article = $this->articleHashingService->resolveHash($hash); $article->setPid(self::getCurrentPageId()); $articles->attach($article); if ($persist && $article->_isNew()) { $product = $article->getProduct(); $product->addArticle($article); $this->productRepository->update($product); $this->articleRepository->add($article); } } if ($persist) { $this->persistenceManager->persistAll(); } return $articles; }
/** * Sets property product based on object or identifier * * @param integer|\Abra\Cadabra\Domain\Model\Product $product * @throws \Abra\Cadabra\Exception */ protected function setProduct($product) { $obj = new self::$productModel(); if (!$product instanceof $obj && !is_integer($product)) { throw new \Abra\Cadabra\Exception('Property "product" must be an instance of ' . self::$productModel . ' or an integer.', 1455030395); } elseif (is_integer($product)) { $this->product = $this->productRepository->findByIdentifier($product); if (!$this->product instanceof $obj) { throw new \Abra\Cadabra\Exception('Product could not be fetched from database.', 1455102729); } } else { $this->product = $product; } }
/** * list * * @return void */ public function listAction() { $products = $this->productRepository->findAll(); $this->view->assign('products', $products); }