vendor/bitbag/elasticsearch-plugin/src/PropertyBuilder/ProductCodeBuilder.php line 23

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file has been created by developers from BitBag.
  4.  * Feel free to contact us once you face any issues or want to start
  5.  * another great project.
  6.  * You can find more information about us on https://bitbag.io and write us
  7.  * an email on hello@bitbag.io.
  8.  */
  9. declare(strict_types=1);
  10. namespace BitBag\SyliusElasticsearchPlugin\PropertyBuilder;
  11. use Elastica\Document;
  12. use FOS\ElasticaBundle\Event\PostTransformEvent;
  13. use Sylius\Component\Core\Model\ProductInterface;
  14. final class ProductCodeBuilder extends AbstractBuilder
  15. {
  16.     public const PROPERTY_NAME 'code';
  17.     public function consumeEvent(PostTransformEvent $event): void
  18.     {
  19.         $this->buildProperty(
  20.             $event,
  21.             ProductInterface::class,
  22.             function (ProductInterface $productDocument $document): void {
  23.                 $document->set(self::PROPERTY_NAME$product->getCode());
  24.             }
  25.         );
  26.     }
  27. }