-
Notifications
You must be signed in to change notification settings - Fork 3
Ajout d'un champs dans l'indexation
Jonathan edited this page Aug 30, 2024
·
1 revision
1. Créer un listener de l'indexation souhaité, ici la website-search et ajouter la méthode onWebsiteSearchIndex
class AddTestFieldToIndexListener
{
public function onWebsiteSearchIndex(IndexEntityEvent $event): void
{
/** @var Product[] $products */
$products = $event->getEntities();
//Add data to index
foreach ($products as $product) {
$event->addField(
$product->getId(),
'test_field',
1,
true
);
}
}
}
Oro\Bundle\ProductBundle\Entity\Product:
alias: oro_product_WEBSITE_ID
fields:
-
name: test_field
type: integer
store: true
AppBundle\EventListener\AddTestFieldToIndexListener:
tags:
- { name: kernel.event_listener, event: oro_website_search.event.index_entity.product, method: onWebsiteSearchIndex }