Not all catalog items returning

Hi there.

I have recently signed up and I am using a barebones api to do some testing.

I have then created an app and imported products / categories etc from my clients account, so far so good. There are about 74 items, and 4 categories.

However, when i go to grab items, unfiltered, I get 4 results.
If I attempt to filter by returning only categories, I get 1 result.
If I attempt to filter by returning only items, I get 3 results.

So for some reason only I only ever get 4 results total.

Here is the code I am using
// Creating the client

$this->client = new SquareClient([
  'accessToken' => env('SQUARE_TOKEN'),
  'environment' => Environment::SANDBOX
]);

// Grabbing all items

$api = $this->client->getCatalogApi();
try {
  $response = $api->listCatalog();
  print_r($response->getResult());
} catch (\Exception $e) {
  echo '<div style="color: #f00">';
  print_r($e);
  echo '</div>';
}

// Check for only items

$api = $this->client->getCatalogApi();
try {
  $response = $api->listCatalog(null, 'ITEM');
  print_r($response->getResult());
} catch (\Exception $e) {
  echo '<div style="color: #f00">';
  print_r($e);
  echo '</div>';
}

// Searching for categories only

$api = $this->client->getCatalogApi();
$categories = [];
try {
  $body = new \Square\Models\SearchCatalogObjectsRequest;
  $body->setObjectTypes([\Square\Models\CatalogObjectType::CATEGORY]);
  $body->setLimit(100);
  $response = $api->searchCatalogObjects($body);
  print_r($response);
} catch (\Exception $e) { }

Is there something that I am doing wrong?
I am really confused as to what is happening

1 Like

Hi @refineddigital welcome to the forums!

Just to confirm, you imported the items into your sandbox, not production, right? If so, can you provide your sandbox app id and I’ll take a look on my side to see what might be going on?

Hi @sjosey

Wow, I feel like an absolute idiot.
Apparently, I had indeed imported products into the wrong dashboard, I really don’t know how I missed that :confused:

Thanks!

1 Like

Ha, no worries at all :slight_smile:. It can be deceiving! Glad you figured it out, let me know if you run into anything else of course!

Thanks @sjosey will do