Skip to content

Commit

Permalink
pick first sku
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes committed Jun 8, 2022
1 parent 6a9fca0 commit 7ddc393
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/api/src/platforms/vtex/utils/canonical.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { Product } from '../clients/search/types/ProductSearchResult'

export const canonicalFromProduct = ({ items, linkText }: Product) => {
// Sort by id so we always use the same canonical regardless of sku availability/ordering
const [{ itemId }] = items.sort(
(i1, i2) => Number(i1.itemId) - Number(i2.itemId)
)

return `/${linkText}-${itemId}/p`
}
export const canonicalFromProduct = ({
items: [{ itemId }],
linkText,
}: Product) => `/${linkText}-${itemId}/p`

0 comments on commit 7ddc393

Please sign in to comment.