Products

$envless->products->listAll()

Collect every visible product into one array

php
/** @return list<ProductResource> */
public function listAll(
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    ?string $order = null,
    int|float|null $timeout = null,
): array

Walks every page and returns a single flat array. Each request asks for the maximum page size of 100 and the walk stops as soon as the API reports no more rows.

The pagination envelope is discarded, so call list once when you need totalCount. A limit you pass here is the per-request page size, not a cap on how many products come back, and an offset is the starting point of the whole walk. There is no bound on the number of requests or on the size of the array, so on a large workspace prefer iterate.

Example

php
use Envless\Envless;

$envless = new Envless();

$products = $envless->products->listAll();
$private = array_filter(
    $products,
    static fn(array $product): bool => $product['isPrivate'],
);

echo count($private), PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$limitintNoPage size for each underlying request, capped at 100.
$offsetintNoRow to start the walk from.
$searchstringNoCase-insensitive substring match against product name and slug.
$orderstringNoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
$timeoutint|floatNoSeconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

An list<ProductResource> with every product the key can see.

Reads the products collection. list returns one page as an Envless\Result\Page with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.

Worth knowing

  • A failure on any page fails the whole call, so a partial result is never returned.

Required scopes

products:read

Underlying endpoint

GET /products

Request and response schema, every error code, and a live playground.

In TypeScript

envless.products.listAll()

The same method in @goenvless/sdk, with the same request, retries and errors.