public function onProductSave(ProductSavedEvent $event) { $product = $event->getProduct(); $this->repository->saveAvailability($product->getId()->getValue(), $product->isAvailable()); if ($this->persister->handlesObject($product)) { $this->persister->insertOne($product); } }