Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

V2 Products API handler

GetProduct

OrderHandlerDescription
500GetProductRetrieves product information using the GetProductCollection service.

  • Key functionality
    • Creates a GetProductCollectionParameter from the input parameter.
    • Calls productService.GetProductCollection to get product details.
    • Ensures exactly one active product is found.
  • Skip conditions
    • Returns error if GetProductCollection fails.
    • Returns error if no products or more than one product is found.
    • Returns error if the product is not active.
  • Data modifications
    • Sets result.ProductDto with the retrieved product information.
600AddToRecentlyViewedAdds the viewed product to the user's recently viewed products list.

  • Key functionality – Calls catalog pipeline to add product to recently viewed list.
  • Skip conditions
    • Skipped if parameter.AddToRecentlyViewed is false.
    • Skipped if widget settings have disabled recently viewed functionality.
  • Data modifications – Updates recently viewed products in the user's session.

GetProductCollection

OrderHandlerDescription
500DisableLazyLoadingDisables lazy loading for the database context.

  • Key functionality– Prevents inadvertent lazy loading of related entities during handler execution.
  • Skip conditions – None; always executes.
  • Data modifications – Sets DisableLazyLoading on the unit of work's data provider.
600ValidateContextValidates the request context and parameters.

  • Key functionality
    • Verifies user has permission to view products.
    • Ensures API compatibility with pricing and inventory settings.
    • Validates parameter combinations and dependencies.
  • Skip conditions – Returns error if validation fails.
  • Data modifications – Sets result.GetProductSettingsResult with product settings.
700ValidateApplyPersonalizationValidates personalization application conditions.

  • Key functionality – Determines if personalization should be applied based on user status and personas.
  • Skip conditions
    • Skips personalization if ApplyPersonalization parameter is false.
    • Skips if user is in CMS shell or is a remembered/signed-in user.
    • Skips if no personalization session ID exists.
    • Skips if no auto-assign personas are available.
  • Data modifications
    • Sets result.PersonalizationSessionId.
    • Sets result.AutoAssignGuestUserPersonas.
    • May modify parameter.ApplyPersonalization to false.
800GetProductIdsForExtendedNamesResolves product IDs from various product identifiers.

  • Key functionality
    • Checks for product replacement.
    • Converts extended names, names, or ERP numbers to product IDs.
    • Enforces product visibility restrictions if needed.
  • Skip conditions – Skips if no product identifiers are provided.
  • Data modifications – Sets parameter.ProductIds with resolved product IDs.
900GetFrequentlyPurchasedRetrieves frequently purchased products.

  • Key functionality – Gets frequently purchased products through catalog pipeline.
  • Skip conditions – Skips if GetFrequentlyPurchased parameter is false.
  • Data modifications
    • Stores result.GetFrequentlyPurchasedProductsResult.
    • Updates parameter.ProductErpNumbers.
1000GetRecentlyPurchasedRetrieves recently purchased products.

  • Key Functionality – Gets recently purchased products through catalog pipeline.
  • Skip Conditions – Skips if GetRecentlyPurchased parameter is false.
  • Data Modifications
    • Stores result.GetRecentlyPurchasedProductsResult.
    • Updates parameter.ProductErpNumbers.
1100GetAlsoPurchasedRetrieves "also purchased" product recommendations.

  • Key functionality
    • Gets products commonly purchased alongside products in current cart.
    • Applies pagination to the results.
  • Skip conditions
    • Skipped if GetAlsoPurchased parameter is false.
    • Skipped if cart is empty.
  • Data modifications – Updates parameter.ProductIds with also purchased product IDs.
1200GetRecentlyViewedRetrieves recently viewed products.

  • Key functionality – Gets recently viewed products through catalog pipeline.
  • Skip conditions – Skips if GetRecentlyViewed parameter is false.
  • Data modifications
    • Stores result.GetRecentlyViewedProductsResult.
    • Updates parameter.ProductErpNumbers.
1300GetTopSellersRetrieves top-selling products.

  • Key functionality
    • Gets top-selling products based on weighted scores.
    • Filters by category, brand, or product line if specified.
    • Supports randomization of recommended products.
  • Skip conditions – Skips if GetTopSellers parameter is false.
  • Data modifications – Updates parameter.ProductIds with top-selling product IDs.
1400GetSiteCrossSellsRetrieves site-level cross-sell products.

  • Key functionality
    • Gets active cross-sell products defined at the website level.
    • Filters for visible products and parent products for styled variants.
  • Skip conditions – Skips if GetSiteCrossSells parameter is false.
  • Data modifications – Updates parameter.ProductIds with site cross-sell product IDs.
1500FindProductsWithSearchExecutes product search using search criteria.

  • Key functionality
    • Configures comprehensive search parameter from request parameters.
    • Executes search through catalog pipeline.
    • Handles facet visibility based on settings.
  • Skip conditions – Skips if ProductIds or ProductExtendedNames are already populated.
  • Data modifications
    • Stores result.ProductSearchResult.
    • Sets result.HideFacetsUntilCategorySelected.
1510GetMissingVariantsRetrieves variant products potentially missing from search results.

  • Key functionality
    • Identifies missing variant products from frequently/recently purchased items.
    • Validates visibility of variant products.
  • Skip conditions – Skips if not GetFrequentlyPurchased and not GetRecentlyPurchased.
  • Data modifications – Adds visible variant product IDs to result.AdditionalProductIds.
1600ProcessSearchResultsProcesses search results into product DTOs.

  • Key functionality
    • Converts search results to ProductDto objects.
    • Populates result metadata (pagination, sorting options, and so on).
    • Handles "did you mean" suggestions and corrected queries.
  • Skip conditions – Skips if ProductIds or ProductExtendedNames are populated.
  • Data modifications
    • Populates result.ProductDtos.
    • Sets pagination, sorting, and search metadata.
1700PopulateContextDataPopulates context-specific data in product DTOs.

  • Key functionality – Enriches product DTOs with context-dependent information.
  • Skip conditions – Skips if ProductDtos is empty.
  • Data modifications – Updates result.ProductDtos with context data.
1800GetExpandedProductDataRetrieves expanded product data from database.

  • Key functionality
    • Configures product data retrieval parameters.
    • Gets expanded product details from repository.
    • Creates product DTOs for products by ID or additional products.
  • Skip conditions – Skips if no product IDs, no product DTOs, and no additional product IDs.
  • Data modifications
    • Stores result.GetProductDataResult.
    • Populates or updates result.ProductDtos.
    • Updates product visibility based on rule engine evaluation.
1900PopulateExpandedProductDataPopulates expanded product data into DTOs.

  • Key functionality
    • Adds variant traits, content, images, documents, specifications, and so on.
    • Gets kit product data and visibility.
    • Handles product translation.
  • Skip conditions – Skips if ProductDtos is empty.
  • Data modifications
    • Enriches result.ProductDtos with expanded details.
    • Filters out products found in search but not in database.
2000 SortByErpNumbersSorts products by ERP numbers.

  • Key functionality
    • Sorts product DTOs by the order of their ERP numbers.
    • Updates sort options accordingly.
  • Skip conditions – Skips if not GetFrequentlyPurchased or GetRecentlyViewed.
  • Data modifications
    • Re-orders result.ProductDtos.
    • Updates result.SortOrder and result.SortOptions.
2100SortByProductIdsSorts products by product IDs.

  • Key functionality
    • Sorts product DTOs by the order of their IDs.
    • Updates sort options accordingly.
  • Skip conditions – Skips if not GetAlsoPurchased, GetTopSellers, or GetSiteCrossSells.
  • Data modifications
    • Re-orders result.ProductDtos.
    • Updates result.SortOrder and result.SortOptions.
2200SortByRecentlyPurchasedSorts and configures recently purchased products.

  • Key functionality
    • Joins product DTOs with recently purchased products data.
    • Sets the correct unit of measure as default for each product.
  • Skip conditions – Skips if not GetRecentlyPurchased.
  • Data modifications
    • Updates result.ProductDtos with correct unit of measure defaults,
    • Updates result.SortOrder and result.SortOptions.
2300SortAndPageByPriceSorts products by price and applies pagination.

  • Key functionality
    • Gets product pricing from pricing pipeline if needed.
    • Sorts products by price (low to high or high to low).
    • Applies pagination to the sorted results.
  • Skip conditions
    • Skipped if using list pricing.
    • Skipped if sort order is not price-based.
    • Skipped if sort option is not available.
  • Data modifications
    • Updates result.ProductDtos with pricing data and applies sorting/paging.
    • Updates result.SortOrder and result.SortOptions.
2400CreatePersonalizationCreates personalization events.

  • Key functionality – Creates dynamic personalization events for product-related personas.
  • Skip conditions
    • Skipped if ApplyPersonalization is false.
    • Skipped if no personalization persona IDs are available.
  • Data modifications – Inserts personalization events into event repository.
2500UpdatePersonalizationUpdates user personas based on personalization events.

  • Key functionality
    • Counts personalization events.
    • Assigns additional personas to users who meet threshold criteria.
  • Skip conditions:
    • Skipped if ApplyPersonalization is false.
    • Skipped if there are no eligible personas.
  • Data modifications – Updates user's assigned personas in site context.

GetRelatedProductCollection

OrderHandlerDescription
500ValidateContextValidates the product relationship parameter.

  • Key functionality
    • Retrieves valid relationship types from the SystemListValue table.
    • Validates that the specified relationship exists and is valid.
  • Skip conditions
    • Returns error if relationship parameter is blank.
    • Returns error if relationship is not in the list of valid relationships.
  • Data modifications – None beyond error handling.
600GetRelatedProductIdsRetrieves IDs for products related to the specified product.

  • Key functionality
    • Sets default page size based on storefront API and catalog settings.
    • Retrieves related products in batches from the ProductRelatedProduct table.
    • Filters for products with the specified relationship type.
    • Gets visible products and includes styled product variants with visible parents.
    • Applies paging to the result set.
  • Skip conditions – Continues to next handler without further processing if no visible related product IDs are found.
  • Data modifications
    • Sets result.AllRelatedProductIds with all related product IDs.
    • Sets result.VisibleRelatedProductIds with filtered and paged product IDs.
700GetRelatedProductCollectionRetrieves product information for the related product IDs.

  • Key functionality
    • Creates GetProductCollectionParameter using visible related product IDs.
    • Calls productService.GetProductCollection to get product details.
    • Orders the products based on the order in AllRelatedProductIds.
    • Sets sort order to Relevance and filters sort options accordingly.
  • Skip conditions – Skips if no visible related product IDs are present.
  • Data modifications
    • Sets result.ProductDtos with ordered product details.
    • Sets result.SortOrder to Relevance.
    • Sets result.SortOptions to only include Relevance sort option.

GetAlsoPurchasedCollection

OrderHandlerDescription
500GetAlsoPurchasedProductIdsRetrieves product IDs for products commonly purchased with a specified product.

  • Key functionality
    • Sets the default page size based on storefront API settings.
    • Sets the page size based on catalog general settings or defaults to storefront API settings.
    • Retrieves both all also-purchased product IDs and visible also-purchased product IDs.
    • Applies paging to the visible also-purchased product IDs.
  • Skip conditions – Continues to next handler without further processing if no visible also-purchased product IDs are found.
  • Data modifications
    • Sets parameter.DefaultPageSize and parameter.PageSize.
    • Sets result.AllAlsoPurchasedProductIds with all related product IDs.
    • Sets result.VisibleAlsoPurchasedProductIds with filtered and paged product IDs.
600GetAlsoPurchasedCollectionRetrieves product information for the also-purchased product IDs.

  • Key functionality
    • Creates GetProductCollectionParameter using visible also-purchased product IDs.
    • Calls productService.GetProductCollection to get product details.
    • Orders the product DTOs based on the order in AllAlsoPurchasedProductIds.
    • Sets sort order to Relevance and filters sort options accordingly.
  • Skip conditions – Skips processing if no visible also-purchased product IDs are present.
  • Data modifications
    • Sets result.ProductDtos with ordered product details.
    • Sets result.SortOrder to Relevance
    • Sets result.SortOptions to only include Relevance sort option.

GetVariantChild

OrderHandlerDescription
500GetVariantChildRetrieves a single variant child product.

  • Key functionality
    • Creates a GetVariantChildCollectionParameter from the input parameter.
    • Calls productService.GetVariantChildCollection to get variant child details.
    • Ensures exactly one active variant child product is found.
  • Skip conditions
    • Returns error if GetVariantChildCollection fails.
    • Returns error if no products or more than one product is found.
    • Returns error if the product is not active.
  • Data modifications – Sets result.ProductDto with the retrieved variant child product information.

GetVariantChildCollection

OrderHandlerDescription
500DisableLazyLoadingDisables lazy loading for the database context.

  • Key functionality – Prevents inadvertent lazy loading of related entities during handler execution.
  • Skip conditions – None; always executes.
  • Data modifications – Sets DisableLazyLoading on the unit of work's data provider.
600ValidateContextValidates the request context and parameter values.

  • Key functionality
    • Retrieves product settings to verify user permissions.
    • Validates parameter combinations and dependencies.
  • Skip conditions
    • Returns error if user cannot see products.
    • Returns error if attribute filter flags are set but attributes are not being retrieved.
    • Returns error if both ProductId and ProductIds are specified.
  • Data modifications – Sets result.GetProductSettingsResult with product settings.
700GetVariantChildIdsRetrieves IDs for variant child products of the specified parent(s).

  • Key functionality
    • Queries database for products with StyleParentId matching the input product ID(s).
    • Filters for a specific variant child if VariantChildId is specified.
    • Applies sorting based on the Sort parameter.
    • Gets visible variant child products by checking product restrictions.
    • Applies paging to the result set.
  • Skip conditions – Continues to next handler without further processing if no visible variant child IDs are found.
  • Data modifications
    • Sets result.AllVariantChildIds with all variant child IDs.
    • Sets result.VisibleVariantChildIds with filtered and paged variant child IDs.
    • Sets default parameter.PageSize if not specified.
800GetVariantChildDataRetrieves detailed data for the variant child products.

  • Key functionality
    • Configures GetProductDataParameter with necessary expand options.
    • Retrieves comprehensive product data including brands, product lines, images, and so on.
  • Skip conditions –None, if previous handlers have populated VisibleVariantChildIds.
  • Data modifications – Sets result.GetProductDataResult with comprehensive product data.
900ProcessVariantChildDataProcesses product data into DTOs with all necessary business logic.

  • Key functionality
    • Creates ProductDto objects for each variant child.
    • Applies business rules for product visibility and purchasing restrictions.
    • Populates variant-specific data including traits, content, specifications, and so on.
    • Configures available sort options for variant children.
  • Skip conditions – Skips if GetProductDataResult is null or contains no products.
  • Data modifications
    • Populates result.ProductDtos with fully processed variant child product DTOs.
    • Sets result.SortOptions with applicable sort types for variant children.