Hello all!
I am trying to get the product and standard price but i only get the ID value.
Here is the code:
PHP Code:
public function GetProductDescriptionAndPrice($ProductId)
{
session_start();
$location = $_SESSION['location'];
$sessionId = $_SESSION['sessionId'];
$wsdl = $_SESSION['wsdl'];
$username = $_SESSION['usr'];
$password = $_SESSION['pwd'];
session_write_close();
$client = new SforcePartnerClient();
$sforceSoapClient = $client->createConnection('../'.$wsdl);
$client->setEndpoint($location);
$client->setSessionHeader($sessionId);
$loginResult = $client->login($username, $password);
//Get Description and Price
$query = "SELECT Id, Name, Family, IsActive, Description, ProductCode, (SELECT UnitPrice FROM PricebookEntries) FROM Product2 where id = '".$ProductId."'";
$queryResult = $client->query($query);
$records = $queryResult->records;
$counter = 0;
foreach ($records as $record)
{
$sObject = new SObject($record);
$Id = $sObject->Id;
$Name = $sObject->fields->Name;
$Description = $sObject->fields->Description;
$ProductCode = $sObject->fields->ProductCode;
$qr = $sObject->queryResult[0]->records;
foreach ($qr as $record2)
{
$UnitPrice = $record2->fields->UnitPrice;
}
$counter++;
}
$ProdArr = array();
$ProdArr['Description'] = $Description;
$ProdArr['UnitPrice']= $UnitPrice;
$ProdArr['Id']= $Id;
return $ProdArr;
}
What am i doing wrong?
Is there a better way to do this?
Thnx in advance!!
Bookmarks