我正在尝试从 Netsuite 中的某个仓库退回所有库存。我遇到了一些问题,想知道是否有人可以指出正确的方向。我要查询的仓库的 internalId 是 16。当我进行搜索时,它返回 0 个项目——但不会失败。
这是我正在使用的 PHP 代码。
<?php
require_once 'PHPtoolkit.php';
require_once 'login_info.php';
global $myNSclient;
$internalID = '16'; //Internal ID of the warehouse I want to query to see what inventory it has
$inventorySearch = new nsComplexObject("ItemSearchBasic");
$searchValue = new nsRecordRef(array('type' => 'location', 'internalId' => $internalID ));
$multiSelect = new nsComplexObject('SearchMultiSelectField');
$multiSelect->setFields(array('operator'=>'anyOf','searchValue'=>$searchValue,"operatorSpecified" => true));
$inventorySearch->setFields(array('location'=>$multiSelect));
try
{
$searchResponse = $myNSclient->search($inventorySearch);
$totalRecords = $searchResponse->totalRecords;
if ($totalRecords > 0)
{
echo "records found";
foreach ($searchResponse->recordList as $record)
{
echo "<pre>";
print_r($record);
echo "</pre>";
}
}
else
{
echo "No result found.";
}
}
catch (Exception $e)
{
echo $e;
echo "Item is not found. Please try again.";
exit();
}
这是 SOAP 请求
<?xml version="1.0" encoding="UTF-8" ?>
- <Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:core_2011_2.platform.webservices.netsuite.com" xmlns:ns2="urn:common_2011_2.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="urn:messages_2011_2.platform.webservices.netsuite.com">
- <Header>
- <passport actor="http://schemas.xmlsoap.org/soap/actor/next">
<email>xxxxx</email>
<password>[Content Removed for Security Reasons]</password>
<account>xxxxxx</account>
<role internalId="3" xsi:type="RecordRef" />
</passport>
</Header>
- <Bod
y>
- <search>
- <searchRecord xsi:type="ItemSearchBasic">
- <location operator="anyOf">
<searchValue internalId="16" type="location" />
</location>
</searchRecord>
</search>
</Body>
</Envelope>
最佳答案
$inventorySearch = new nsComplexObject("ItemSearchBasic");
$inventorySearch->setFields(array(
"location" => array(
"operator" => "anyOf",
"searchValue" => array(
"type" => "location",
"internalId" => $internalId
)
)
));
然后,做你的 try/catch。
但正如我所看到的,您想要获得商品可用性。这是一个完全不同的调用。
$filter = new nsComplexObject ( 'ItemAvailabilityFilter' );
$filter->setFields ( array (
"location" => array (
"operator" => "anyOf",
"searchValue" => new nsRecordRef ( array (
"type" => "location",
"internalId" => $internalId
) )
)
) );
关于php - Netsuite PHP ItemSearchBasic 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11299850/