Skip to content

Instantly share code, notes, and snippets.

@groggu
Last active October 12, 2015 19:54
Show Gist options
  • Save groggu/eb000d7bc00bca3cbfe9 to your computer and use it in GitHub Desktop.
Save groggu/eb000d7bc00bca3cbfe9 to your computer and use it in GitHub Desktop.
Lookup NetSuite promotion by coupon code (from custom Magento module)
//assumes you are using the PHPToolKit and have already
// require_once 'lib/NetSuite/NetSuiteService.php';
private function _getNsPromoCode($magePromoCode){
$service = new NetSuiteService();
//get the ID of the coupon by code
$searchData = new SearchStringField();
$searchData->operator = "is";
$searchData->searchValue = $magePromoCode;
$search = new CouponCodeSearchBasic();
$search->code = $searchData;
$request = new SearchRequest();
$request->searchRecord = $search;
$searchResponse = $service->search($request);
if ($searchResponse->searchResult->status->isSuccess) {
$result = $searchResponse->searchResult->recordList->record;
$promoId = $result[0]->promotion->internalId;
return $promoId;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment