1
votes

I am trying to get a list of items with their price + stock from a saved search I set up on Netsuite. This is my code:

$service = new NetSuiteService();
$service->setSearchPreferences(false, 1000, false);

$search = new ItemSearchAdvanced();
$search->savedSearchId = "1226";  // Your SavedSearch ID.

$request = new SearchRequest();
$request->searchRecord = $search;

$searchResponse = $service->search($request);

if (!$searchResponse->searchResult->status->isSuccess) {
    echo "SEARCH ERROR";
} else {
    echo "SEARCH SUCCESS, records found: " . 
    $searchResponse->searchResult->totalRecords . "\n";

    var_dump($searchResponse);
}

However, although it has filtered results according to the criteria filter I set, It is returning every field for the items, rather than just the columns I have set in results -> columns on the saved search.

This seems to be making it very slow, It takes around 50 seconds to retrieve the 330 items.

Is there a way to make it only return select fields from the item, or just the columns I have set up in the saved search?

Thanks!

1

1 Answers

1
votes
$service->setSearchPreferences(false, 20, true);

The above code sets the preferences for your search:

  1. Body Fields Only (boolean)
  2. Page Size (integer)
  3. Return Search Columns (boolean)

It's #3 that controls the behavior you are experiencing. You set it to false (don't return search columns). It needs to be set to true.