product.data-mapper.ts 680 B

12345678910111213141516171819202122
  1. import { Product } from '@vendure/core';
  2. import { EntitySearchIndexItem } from '../types';
  3. import { VendureEntityDataMapper } from './vendure-entity.data-mapper';
  4. export class ProductDataMapper extends VendureEntityDataMapper {
  5. map(entity: Product): Partial<EntitySearchIndexItem> {
  6. const product = super.map(entity);
  7. return {
  8. ...product,
  9. entityName: Product.name,
  10. thumbnailUrl: entity.featuredAsset ? entity.featuredAsset.preview : undefined,
  11. title: entity.name,
  12. description: entity.description,
  13. metadata: {
  14. enabled: entity.enabled,
  15. },
  16. };
  17. }
  18. }