Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Item information from Netsuite with PHP

Tags:

php

netsuite

I'm trying to search for a product by ID in NetSuite using the PHP Toolkit. As far as I can tell from my Google searches, NetSuite doesn't document their PHP Toolkit very well. From what I could gather, I have this:

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

$search = new ItemSearchBasic();
$search->searchValue = array('internalId' => $id);
$search->type = "item";

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

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

But that just gives me a bunch of random crap. Can anyone help me with this?

like image 794
Tim Pogue Avatar asked Sep 05 '14 00:09

Tim Pogue


1 Answers

So after more searching and crying, I finally found a solution.

function getProduct($id) {

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

  $itemInfo = new SearchMultiSelectField();
  $itemInfo->operator = "anyOf";
  $itemInfo->searchValue = array('internalId' => $id);

  $search = new ItemSearchBasic();
  $search->internalId = $itemInfo;

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

  $searchResponse = $service->search($request);
  $products = $searchResponse->searchResult->recordList->record;

  return $products;

}
like image 138
Tim Pogue Avatar answered Nov 03 '22 12:11

Tim Pogue