diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-08 17:09:56 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-08 17:09:56 +0700 |
| commit | 616d8ffc973eba673069243ec8981b5234234fe5 (patch) | |
| tree | bd3aac41921bbad8959e0c4b6b083aabd7d097e3 /src-migrate/services | |
| parent | bd62835db7dc521a17d6b0aea81badaae6ade95c (diff) | |
<iman> add similar product template
Diffstat (limited to 'src-migrate/services')
| -rw-r--r-- | src-migrate/services/product.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src-migrate/services/product.ts b/src-migrate/services/product.ts index 51667eb9..ec5435cd 100644 --- a/src-migrate/services/product.ts +++ b/src-migrate/services/product.ts @@ -21,6 +21,7 @@ export const getProductById = async ( }; export interface GetProductSimilarProps { + source?: string; name: string; except?: { productId?: number; @@ -34,18 +35,22 @@ export interface GetProductSimilarRes { num_found: number; num_found_exact: boolean; start: number; + source: string; } export const getProductSimilar = async ({ name, except, limit = 30, + source, }: GetProductSimilarProps): Promise<GetProductSimilarRes> => { let dataflashSale = null const flashSale = await odooApi('GET', '/api/v1/flashsale/header') if (flashSale && flashSale.length > 0) { const dataFlash = await productSearchApi({ - query: `fq=flashsale_id_i:${flashSale[0].pricelist_id}&fq=flashsale_price_f:[1 TO *]&limit=4`, + query: `fq=flashsale_id_i:${flashSale[0].pricelist_id}&fq=flashsale_price_f:[1 TO *]&limit=${ + source === 'bottom' ? '4' : '1' + }`, operation: 'AND' }) @@ -61,6 +66,12 @@ export const getProductSimilar = async ({ qty_sold: product.qtySold, lowestPrice: undefined })); + if (source === 'bottom') { + dataflashSale = dataflashSale.slice('2', '4') + } else { + dataflashSale = dataflashSale + } + console.log("dataflashSale",dataflashSale) } const query = [ `q=${name}`, |
