Skip to content

Documentation

PHP SDK: Wildberries: Products in Selected Regions

This source is available to scenarios for a site created with the Wildberries solution. When creating each scenario, select its products, regions, and any needed search options. Scenario settings are separate: creating another scenario does not change the product selection of an existing one.

Methods

products

products(): array returns the product codes selected for this scenario as strings.

regions

regions(): array returns the selected regions. Each has an id, name, and code. A scenario must visit each region if several were chosen. Prices may differ.

cards

cards(array $ids, string $regionId): array retrieves up to 50 cards in one call. Pass the id of a region from regions(). You may request selected product codes and products the scenario found through search() or analogs(). Results contain id, title, brand, supplier, price_rub, base_price_rub, discount_percent, stock_total, available, sizes, rating, feedbacks, supplier_rating, subject_id, and url. A price may be null; an absent card means the product was not found in that region.

categoryQuery

categoryQuery(): string returns the category phrase entered when the scenario was created.

maxPages

maxPages(): int returns the selected search depth, from 1 to 20 pages.

search

search(string $regionId, int $page): array retrieves a live page for the selected category. Results contain cards, total, and page, with 100 products per page. This method is available only to an Assortment by category scenario. Its query and page count are limited by scenario settings.

analogs

analogs(string $regionId): array searches for similar cards using your own product's name, keeps products of the same type, and remembers new matches. It returns own_id, ids (all monitored alternatives), new_ids, found_now, and the search phrase query. Call it on every run to extend the list.

details

details(string $id): array reads the description, attributes, composition, category, seller's product code, certificate information, and colors of a selected or discovered product. These values come from the public product page and are refreshed no more than once per day. If the page is temporarily unavailable, the method reports an error; current price and availability are unaffected.

detailsMany

detailsMany(array $ids): array accepts up to 50 product codes and returns descriptions indexed by code. If one page is temporarily unavailable, its entry is absent; the other products can still be processed. Use this method for large comparisons.

title

title(array $card): string returns a title from a retrieved card.

characteristics

characteristics(array $card): array returns attributes from the supplied array. For a complete product page, call details($id) and read its characteristics key.

Example

<?php
function run(\Sdk\Context $ctx): void
{
    $source = $ctx->wildberries();
    $ids = $source->products();
    foreach ($source->regions() as $region) {
        foreach (array_chunk($ids, 50) as $batch) {
            foreach ($source->cards($batch, $region['id']) as $card) {
                if ($card['price_rub'] === null) {
                    continue;
                }
                $ctx->emit([
                    'wb_id' => $card['id'],
                    'wb_region_id' => $region['id'],
                    'title' => $source->title($card),
                    'price_rub' => $card['price_rub'],
                ], $card['id'].':'.$region['id']);
            }
        }
    }
}

Editor suggestions show each method's signature and purpose. Code validation highlights syntax errors and obviously incorrect argument types. PHP makes the final check for complex expressions during a trial run.

Product photos

Record schemas support image for a primary photo and gallery for up to 50 photos. A scenario emits a URL or URL list. A production run stores the image files and replaces source values with private references, dimensions, and MIME type. Trial runs do not upload files.

Ready-made Wildberries scenarios provide main_image and gallery. Both can be shown as table columns and opened in the shared zoomable gallery. Site settings select Akmelo storage or an S3 connection belonging to the same workspace. Personal scenarios cannot use another team’s storage. A self-hosted agent stores photos locally by default.