/** * @inheritdoc */ public function getJson() { $serializer = new NostoProductCollectionSerializerJson(); return $serializer->serialize($this); }
/** * Returns the whole collection in JSON format. * * @return string the json. * @throws NostoException if the collection is empty. */ protected function getCollectionAsJson() { if ($this->collection->count() === 0) { throw new NostoException('No products found in collection.'); } $serializer = new NostoProductCollectionSerializerJson(); return $serializer->serialize($this->collection); }