arch-atlas

MarketplaceService.getProductById (customer detail)

core/services/marketplace_service.dart · getProductById

data

Overview

Customer-side single-product fetch used by ProductDetailScreen when it can't rely on the route extra. Returns the typed Product including variants with calculated_price.

User Flow

  1. loadProduct(productId) calls marketplaceServiceProvider.getProductById.
  2. Response includes variants + calculated_price (per-region pricing).
  3. Product.fromJson maps the response into the typed entity used by the screen.

Cases & Edge Cases

  • Product not found → throws 'Product not found' which the controller surfaces as state.error.
  • calculated_price requires the `fields=*variants.calculated_price` query — already part of the service method.

Code References

  • lib/src/core/services/marketplace_service.dart:78 // getProductById
  • lib/src/features/shared/marketplace/models/product.dart // Product

API Calls

  • GET/store/physical-products/:productId?fields=*variants.calculated_priceno status

    Customer-side single product fetch (fallback when ProductDetailScreen has no route extra).

    Response
    { product: Product }
    Errors
    • ·product not found → thrown as 'Product not found', surfaced as state.error
    lib/src/features/shared/product_details/views/product_details_screen.dart // loadProduct

    auth: customer. calculated_price requires the explicit fields query.

Notes

Customer + seller views read different endpoints (/store vs /vendor) and don't share a typed contract — be cautious when refactoring.