/** * {@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(); }
public function indexAction(ProductInterface $product) { $this->addBreadCrumbItem(new BreadcrumbItem(['name' => $product->translate()->getName()])); $this->manager->getProductContext()->setCurrentProduct($product); return $this->displayTemplate('index', ['product' => $product]); }