Home > widget-integration > FilterStorageHelper > getCollectionIdByHandleKey

FilterStorageHelper.getCollectionIdByHandleKey() method

Gets collection ID by handle key.

Retrieves the collection ID associated with a collection handle. Returns 0 if the mapping doesn't exist.

Signature:

getCollectionIdByHandleKey(key: string): string | number;

Parameters

Parameter

Type

Description

key

string

The collection handle to lookup

Returns:

string | number

The collection ID, or 0 if not found

Example

Override to add logging:

getCollectionIdByHandleKey(key) {
  const id = super.getCollectionIdByHandleKey(key);
  if (id === 0) {
    console.warn(`Collection ID not found for handle: ${key}`);
  }
  return id;
}