/** * Products class. * * @link ecomm.gitngin.com/wiki/models/products * @file This files defines the Product class. * @author Alexandre Hébert-Vincent. * @since 01-01-2020 */ import IMarketplacePublication from '../../Interfaces/MarketplacePublication'; import { IIndexedProductAlgolia } from '../../Interfaces/Algolia'; import IProduct, { IQueryProps } from '../../Interfaces/Product'; import { SearchResponse } from '@algolia/client-search'; import IProductAttribute from '../../Interfaces/ProductAttribute'; import ProductAttribute from '../ProductAttribute'; import IndexedProduct from '../Indexed/Product'; import IQueryOptions from '../../Interfaces/Query/IProductQueryOptions'; import IDeclination from '../../Interfaces/Declination'; import ITranslation from '../../Interfaces/Translation'; import Declination from '../Declination'; import IAttribute from '../../Interfaces/Attribute'; import Category from '../Category'; import Brand from '../Brand'; import Space from '../Space'; import Org from '../Org'; import { BaseServiceClass } from '../baseService'; import { IExternalProductPriceVariation } from '../../Interfaces/ExternalService/ExternalProductsService'; /** * Product class */ export default class Product extends BaseServiceClass { static fetch: ({ app, api, hpp, page, query, filters, indice, f, space, useProspr }: IQueryProps) => Promise>; /** * Get the product properties */ data: () => IProduct; toCSV: () => { product_attributes: any; declinations: any; brand: any; classes: any; category: any; id?: string | undefined; slug: string; name: ITranslation[]; draft: boolean; description?: ITranslation[] | undefined; full_description?: string | undefined; documents?: import("../../Interfaces/Document").IDocument[] | undefined; panel_descriptions?: import("../../Interfaces/Product").IPanelDescription[] | undefined; product_upsells?: import("../../Interfaces/Product").IProductRecommendation[] | undefined; product_equivalents?: import("../../Interfaces/Product").IProductEquivalent[] | undefined; upsell_sku_list?: string[] | undefined; is_multiple?: boolean | undefined; image_files: import("../../utils/file").IImageInfo[]; suppliers?: import("../../Interfaces/Product").IProductSupplier[] | undefined; services?: any; keywords?: string[] | undefined; tax_family_id?: string | null | undefined; restrict_sale?: import("../../Interfaces/Product").IRestriction[] | undefined; restrict_shipping?: string[] | undefined; exclude_from_free_shipping?: boolean | undefined; seo_info?: import("../../Interfaces/Product").ISEOInfo | undefined; default_size?: string | undefined; default_size_complete?: string | undefined; default_sku?: string | undefined; is_service?: boolean | undefined; is_hidden?: boolean | undefined; is_hidden_in_client_pos?: boolean | undefined; last_update_by?: string | undefined; last_update?: Date | undefined; custom_promo_applies?: boolean | undefined; is_presale?: boolean | undefined; release_date?: string | Date | undefined; promise_to_purchase_association_ids?: string[] | undefined; created_from_external_service?: import("../../Interfaces/Space/IExternalService").ExternalServiceSlugEnum | undefined; disable_price_auto_update?: boolean | undefined; tcg_attributes?: { [key: string]: string; } | undefined; }; allRelationships: () => Promise>; getDefaultSupplier: () => string | undefined; /** * Returns complete relationship object mapped by product interface. * @param relations Array of strings reprensenting the wanted relationships objects. * @returns Partial product IProduct */ relationships: (relations: 'brands'[]) => Promise>; save: (partialProduct?: Partial, options?: { index?: boolean; space?: Space; }) => Promise; private _updateDependancies; private _updateSEOImage; private _updatePanelDescriptionsImage; private _updateBarcode; private _updateInventoryItem; private _updateDeclinationsDiscountRules; private _uploadDeclinationsImages; private _getAttributes; private _addAttribute; private _getCategory; private _getBrand; private _getDeclinations; private _addDeclination; private _saveIndex; private _getIndex; private _deleteIndex; /** * Checks for external values from external services for a sku. * Available services checked (as of now) : G2. * @param space * @param sku */ static checkExternalValuesForDecli: (sku: string, space: Space, org: Org) => Promise<{ [key: string]: any; } | undefined>; callPublicService: (service: any, fromServer?: boolean) => Promise<{ confirmed: boolean; details: any; error?: undefined; } | { confirmed: boolean; error: unknown; details?: undefined; }>; private _updateAllDeclinationsPrice; adaptPriceChartingValues: (pricingMap: any, space: Space) => any; private _updateAllDeclinationsPriceAsync; private _getMarketplacePublications; private _marketplacePublicationsListner; private _createNewPublication; private _updateMarketplacePublication; private _removeMarketplacePublication; private _updateAllDeclinationsPriceUsingCategoryRules; attributes: { get: () => ProductAttribute[]; add: (productAttribute: IProductAttribute) => Promise; }; brand: { get: () => Promise; }; category: { get: () => Promise; }; publications: { get: (options?: IQueryOptions) => Promise<{ id: string; }[]>; listen: (callback: (marketplacePublications: IMarketplacePublication[]) => any, options?: IQueryOptions) => string; update: (sku: string, marketplacePublication: IMarketplacePublication) => Promise; create: (sku: string, marketplacePublication: IMarketplacePublication, space: Space) => Promise; remove: (publicationId: string) => Promise; }; declinations: { get: () => Declination[]; add: (declination: IDeclination) => Promise; update: { priceSync: (pricingMapFromExternalOrCustom: any, attributes: IAttribute[], saveToDatabase?: boolean, updateRegular?: boolean, spaceToUse?: Space) => Promise; priceAsync: (pricingMapFromExternalOrCustom: any) => Promise; byCategoryRules: (basePrices: IExternalProductPriceVariation[], attributeVariationId: string, defaultVariation: string, options?: { saveToDatabase?: boolean; noEvent?: boolean; }) => Promise; }; }; index: { save: (category?: Category) => Promise; get: () => Promise; delete: () => Promise; }; }