$this->syncCategories($store), 'products' => $this->syncProducts($store, $user), ]; } public function syncCategories(WooStore $store): int { $response = $this->client->get($store, 'categories', ['per_page' => 100]); if (! is_array($response)) { return 0; } $items = $response['data'] ?? $response; if (! is_array($items)) { return 0; } $count = 0; foreach ($items as $item) { if (! is_array($item)) { continue; } $this->categories->ingest($store, $item); $count++; } return $count; } public function syncProducts(WooStore $store, ?User $user = null): int { $response = $this->client->get($store, 'products', ['per_page' => 100]); if (! is_array($response)) { return 0; } $items = $response['data'] ?? $response; if (! is_array($items)) { return 0; } $count = 0; foreach ($items as $item) { if (! is_array($item)) { continue; } $externalId = (int) ($item['id'] ?? 0); if ($user && ! $this->subscriptions->canIngestProduct($user, $store, $externalId)) { continue; } $this->products->ingest($store, $item); $count++; } return $count; } }