@@ -221,7 +221,18 @@ def product_thumbnail(self, request):
221
221
full_url = request .build_absolute_uri (image_url )
222
222
return full_url
223
223
return None
224
-
224
+
225
+ def product_thumbnail_xs (self , request ):
226
+ """
227
+ Returns the URL of the first image associated with the product.
228
+ If no image is available, returns None.
229
+ """
230
+ first_image = self .images .first () # Get the first image if it exists
231
+ if first_image and hasattr (first_image , 'image_xs' ) and first_image .image_xs :
232
+ image_url = first_image .image_xs .url
233
+ full_url = request .build_absolute_uri (image_url )
234
+ return full_url
235
+ return None
225
236
226
237
227
238
@@ -385,6 +396,24 @@ def variant_thumbnail(self, request):
385
396
full_url = request .build_absolute_uri (image_url )
386
397
return
387
398
return None
399
+
400
+ def variant_thumbnail_xs (self , request ):
401
+ """
402
+ Returns the URL of the first image associated with the product variant.
403
+ If no image is available, returns None.
404
+ """
405
+ if self .image and hasattr (self .image , 'image_xs' ) and self .image .image_xs :
406
+ image_url = self .image .image_xs .url
407
+ full_url = request .build_absolute_uri (image_url )
408
+ return full_url
409
+
410
+ if self .product .images .exists ():
411
+ first_image = self .product .images .first ()
412
+ if first_image and hasattr (first_image , 'image_xs' ) and first_image .image_xs :
413
+ image_url = first_image .image_xs .url
414
+ full_url = request .build_absolute_uri (image_url )
415
+ return
416
+ return None
388
417
389
418
390
419
def get_valid_stock (self ): # stocks that available for sell
0 commit comments