ChemPal Documentation - v1.6.0
    Preparing search index...

    Function productSeriesKey

    • Derive the product's stable identity key — shared by its base series and every variant series. Prefers the stamped cacheKey, falling back to the URL then the title so scraped products without a stamped key still track.

      Parameters

      • product: Product

        The product to key.

      Returns undefined | string

      The identity key, or undefined when neither an identity nor a supplier is available to key against.

      productSeriesKey({ cacheKey: "889460", supplier: "Carolina", … }); // "3f9c2a…"
      
      export function productSeriesKey(product: Product): string | undefined {
      const identity = product.cacheKey ?? product.url ?? product.title;
      if (identity == null || String(identity).length === 0 || !product.supplier) {
      return undefined;
      }
      return getProductIdentityKey(String(identity), product.supplier);
      }