@@ -67,6 +67,17 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
6767
6868export default async function Product ( { params, searchParams } : Props ) {
6969 const { locale, slug } = await params ;
70+ const options = await searchParams ;
71+
72+ const optionValueIds = Object . keys ( options )
73+ . map ( ( option ) => ( {
74+ optionEntityId : Number ( option ) ,
75+ valueEntityId : Number ( options [ option ] ) ,
76+ } ) )
77+ . filter (
78+ ( option ) => ! Number . isNaN ( option . optionEntityId ) && ! Number . isNaN ( option . valueEntityId ) ,
79+ ) ;
80+
7081 const customerAccessToken = await getSessionCustomerAccessToken ( ) ;
7182 const detachedWishlistFormId = 'product-add-to-wishlist-form' ;
7283
@@ -90,17 +101,6 @@ export default async function Product({ params, searchParams }: Props) {
90101 }
91102
92103 const streamableProduct = Streamable . from ( async ( ) => {
93- const options = await searchParams ;
94-
95- const optionValueIds = Object . keys ( options )
96- . map ( ( option ) => ( {
97- optionEntityId : Number ( option ) ,
98- valueEntityId : Number ( options [ option ] ) ,
99- } ) )
100- . filter (
101- ( option ) => ! Number . isNaN ( option . optionEntityId ) && ! Number . isNaN ( option . valueEntityId ) ,
102- ) ;
103-
104104 const variables = {
105105 entityId : Number ( productId ) ,
106106 optionValueIds,
@@ -121,6 +121,8 @@ export default async function Product({ params, searchParams }: Props) {
121121 const streamableProductInventory = Streamable . from ( async ( ) => {
122122 const variables = {
123123 entityId : Number ( productId ) ,
124+ optionValueIds,
125+ useDefaultOptionSelections : true ,
124126 } ;
125127
126128 const product = await getStreamableProductInventory ( variables , customerAccessToken ) ;
@@ -153,17 +155,7 @@ export default async function Product({ params, searchParams }: Props) {
153155 return removeEdgesAndNodes ( variants ) . find ( ( v ) => v . sku === product . sku ) ;
154156 } ) ;
155157
156- const streamableProductPricingAndRelatedProducts = Streamable . from ( async ( ) => {
157- const options = await searchParams ;
158-
159- const optionValueIds = Object . keys ( options )
160- . map ( ( option ) => ( {
161- optionEntityId : Number ( option ) ,
162- valueEntityId : Number ( options [ option ] ) ,
163- } ) )
164- . filter (
165- ( option ) => ! Number . isNaN ( option . optionEntityId ) && ! Number . isNaN ( option . valueEntityId ) ,
166- ) ;
158+ const streamableProductPricingAndRelatedProducts = Streamable . from ( async ( ) => { ;
167159
168160 const currencyCode = await getPreferredCurrencyCode ( ) ;
169161
0 commit comments