/** * {@inheritdoc} */ public function addProduct(ProductInterface $product, $indexName = ProductIndexerInterface::DEFAULT_INDEX_NAME) { $index = $this->searchIndexManager->getIndex(ProductIndexerInterface::DEFAULT_INDEX_NAME); $document = new Document(); $document->addField(Field::unIndexed('identifier', $product->getId())); $document->addField(Field::text('name', $product->translate('en')->getName())); $document->addField(Field::text('shortDescription', $product->translate()->getShortDescription())); $document->addField(Field::text('description', $product->translate()->getDescription())); $index->addDocument($document); $index->commit(); }
private function addBreadcrumbs(ProductInterface $product) { $category = $product->getCategories()->last(); $paths = $this->get('category.repository')->getCategoryPath($category); /** @var CategoryInterface $path */ foreach ($paths as $path) { $this->getBreadcrumbProvider()->add(new Breadcrumb(['label' => $path->translate()->getName(), 'url' => $this->getRouterHelper()->generateUrl($path->translate()->getRoute()->getId())])); } $this->getBreadcrumbProvider()->add(new Breadcrumb(['label' => $product->translate()->getName()])); }
public function indexAction(ProductInterface $product) : Response { $this->getBreadcrumbProvider()->add(new Breadcrumb(['label' => $product->translate()->getName()])); $this->getProductStorage()->setCurrentProduct($product); return $this->displayTemplate('index', ['product' => $product]); }
public function indexAction(ProductInterface $product) { $this->addBreadCrumbItem(new BreadcrumbItem(['name' => $product->translate()->getName()])); $this->manager->getProductContext()->setCurrentProduct($product); return $this->displayTemplate('index', ['product' => $product]); }