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?
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With