Skip to content

Commit

Permalink
remove logic pdp
Browse files Browse the repository at this point in the history
  • Loading branch information
evertonvargasvtex committed Oct 30, 2024
1 parent 9b09e59 commit 68b4e12
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
6 changes: 2 additions & 4 deletions packages/api/src/platforms/vtex/clients/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ export const IntelligentSearch = (

const segmentCookie = ctx ? getVtexSegment(ctx.headers.cookie) : null;

console.log("search segmentCookie", segmentCookie)

const headers = segmentCookie || segment
const headers = segmentCookie
? {
headers: {
'Cookie': `vtex_segment=${segmentCookie || segment}`,
'Cookie': `vtex_segment=${segmentCookie}`,
},
}
: undefined;
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/platforms/vtex/loaders/sku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ export const getSkuLoader = (_: Options, clients: Clients) => {
const skuIds = keys.map((key) => key.split('-')[0]);
const showInvisibleItems = keys.some((key) => key.split('-')[1] === 'invisibleItems')

const segmentKey = keys.find((key) => key.split('-')[1]?.startsWith('segment:'))
const segment = segmentKey ? segmentKey.split('segment:')[1] : undefined
// const segmentKey = keys.find((key) => key.split('-')[1]?.startsWith('segment:'))
// const segment = segmentKey ? segmentKey.split('segment:')[1] : undefined

console.log("segment getSkuLoader", segment)
// console.log("segment getSkuLoader", segment)
const { products } = await clients.search.products({
query: `sku:${skuIds.join(';')}`,
page: 0,
count: skuIds.length,
showInvisibleItems,
...(segment && { segment })
// ...(segment && { segment })
})

const skuBySkuId = products.reduce((acc, product) => {
Expand Down
9 changes: 4 additions & 5 deletions packages/api/src/platforms/vtex/resolvers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
findSkuId,
findSlug,
transformSelectedFacet,
findSegment
// findSegment
} from '../utils/facets'
import { SORT_MAP } from '../utils/sort'
import { StoreCollection } from './collection'
Expand All @@ -36,7 +36,7 @@ export const Query = {
const locale = findLocale(locator)
const id = findSkuId(locator)
const slug = findSlug(locator)
const segment = findSegment(locator)
// const segment = findSegment(locator)

if (channel) {
mutateChannelContext(ctx, channel)
Expand All @@ -58,7 +58,7 @@ export const Query = {
throw new Error('Invalid SkuId')
}

const sku = await skuLoader.load(segment ? `${skuId}-segment:${segment}` : skuId)
const sku = await skuLoader.load(skuId)

/**
* Here be dragons 🦄🦄🦄
Expand All @@ -77,7 +77,7 @@ export const Query = {
)
}

console.log("product faststore sku")
// console.log("product faststore sku")
return sku
} catch (err) {
console.log("catch")
Expand All @@ -97,7 +97,6 @@ export const Query = {
page: 0,
count: 1,
query: `product:${route.id}`,
segment
})

if (!product) {
Expand Down
7 changes: 3 additions & 4 deletions packages/api/src/platforms/vtex/utils/facets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export const transformSelectedFacet = ({ key, value }: SelectedFacet) => {
case "similars":
case "viewAndBought":
case "accessories":
case "suggestions":
case "segment": {
case "suggestions": {
return [] // remove this facet from search
}

Expand Down Expand Up @@ -90,5 +89,5 @@ export const findLocale = (facets?: Maybe<SelectedFacet[]>) =>
export const findChannel = (facets?: Maybe<SelectedFacet[]>) =>
facets?.find((facet) => facet.key === 'channel')?.value ?? null

export const findSegment = (facets?: Maybe<SelectedFacet[]>) =>
facets?.find((facet) => facet.key === 'segment')?.value ?? undefined
// export const findSegment = (facets?: Maybe<SelectedFacet[]>) =>
// facets?.find((facet) => facet.key === 'segment')?.value ?? undefined

0 comments on commit 68b4e12

Please sign in to comment.