Php Arrays/Table's need to get "EntityId" - php

I am new to tables/arrays and I can't get this to work.
I am trying to get The data of "EntityId", and it doesn't work if I change "Phone" to "EntityId". I tried much more but I can't figure it out on my own. I hope someone can explain what I am doing wrong or maybe I did't notice something.
Any help would be appreciated.
Script
<?php
require_once 'autoload.php';
$username = '*****************';
$password = '*********';
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts);
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
$firstnameField = new ATWS\AutotaskObjects\QueryField('ID');
$firstnameField->addExpression('Equals', '30682996');
$query->addField($firstnameField);
// If you want to debug the XML produced by the Query object
// print($query->asXml());
// Print the results of the query
print_r($client->query($query));
$json = ($client->query($query));
$phone = $json->queryResult->EntityResults->Entity->Phone;
echo $phone;
output
ATWS\AutotaskObjects\QueryResponse Object
( [queryResult] => ATWS\AutotaskObjects\ATWSResponse Object
( [EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object
( [Entity] => ATWS\AutotaskObjects\Contact Object
( [AccountID] => 236
[Active] => 0
[AdditionalAddressInformation] =>
[AddressLine] => Dorpstraat
[AddressLine1] =>
[AlternatePhone] => 040-4444555566
[City] => Veldhoven
[Country] => Netherlands
[CountryID] => 158
[CreateDate] => 2017-11-18T05:36:46.14
[EMailAddress] => Email#email.nl
[Extension] =>
[ExternalID] =>
[FaxNumber] => 467863453
[FirstName] => Ellis
[LastActivityDate] => 2017-11-18T05:36:46.14
[LastModifiedDate] => 2017-11-18T05:36:46.127
[LastName] => Dodo
[MiddleInitial] =>
[MobilePhone] => 061231235
[Note] =>
[Notification] => 1
[Phone] => 040-4444555566
[RoomNumber] =>
[State] => GH
[Title] =>
[ZipCode] => 5890aa
[Fields] =>
[UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object
( [UserDefinedField] => )
[id] => 30682996
[BulkEmailOptOut] =>
[SurveyOptOut] =>
[FacebookUrl] =>
[TwitterUrl] =>
[LinkedInUrl] =>
[PrimaryContact] => ) )
[EntityResultType] => contact
[EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object ( [EntityReturnInfo] => ATWS\AutotaskObjects\EntityReturnInfo Object ( [DatabaseAction] => None [DuplicateStatus] => ATWS\AutotaskObjects\EntityDuplicateStatus Object ( [Found] => [Ignored] => [MatchInfo] => [Fields] => [UserDefinedFields] => ) [EntityId] => 30682996 [Message] => [Fields] => [UserDefinedFields] => ) [Fields] => [UserDefinedFields] => ) [Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object ( [ATWSError] => [Fields] => [UserDefinedFields] => ) [ReturnCode] => 1 ) )
#kunal
output
ATWS\AutotaskObjects\QueryResponse Object ( [queryResult] => ATWS\AutotaskObjects\ATWSResponse Object ( [EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object ( [Entity] => ATWS\AutotaskObjects\Contact Object ( [AccountID] => 236 [Active] => 0 [AdditionalAddressInformation] => [AddressLine] => Dorpstraat [AddressLine1] => [AlternatePhone] => 040-4444555566 [City] => Veldhoven [Country] => Netherlands [CountryID] => 158 [CreateDate] => 2017-11-18T05:36:46.14 [EMailAddress] => Test#email.ciom [Extension] => [ExternalID] => [FaxNumber] => 467863453 [FirstName] => Ellis [LastActivityDate] => 2017-11-18T05:36:46.14 [LastModifiedDate] => 2017-11-18T05:36:46.127 [LastName] => Bommers [MiddleInitial] => [MobilePhone] => 0612312asd35 [Note] => [Notification] => 1 [Phone] => 040-44asd44555566 [RoomNumber] => [State] => NB [Title] => [ZipCode] => 1239aa [Fields] => [UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object ( [UserDefinedField] => ) [id] => 30682996 [BulkEmailOptOut] => [SurveyOptOut] => [FacebookUrl] => [TwitterUrl] => [LinkedInUrl] => [PrimaryContact] => ) ) [EntityResultType] => contact [EntityReturnInfoResults] => ATWS\AutotaskObjects\ArrayOfEntityReturnInfo Object ( [EntityReturnInfo] => ATWS\AutotaskObjects\EntityReturnInfo Object ( [DatabaseAction] => None [DuplicateStatus] => ATWS\AutotaskObjects\EntityDuplicateStatus Object ( [Found] => [Ignored] => [MatchInfo] => [Fields] => [UserDefinedFields] => ) [EntityId] => 30682996 [Message] => [Fields] => [UserDefinedFields] => ) [Fields] => [UserDefinedFields] => ) [Errors] => ATWS\AutotaskObjects\ArrayOfATWSError Object ( [ATWSError] => [Fields] => [UserDefinedFields] => ) [ReturnCode] => 1 ) )
Notice: Undefined property: ATWS\AutotaskObjects\ArrayOfUserDefinedField::$EntityReturnInfoResults in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Notice: Trying to get property of non-object in C:\xampp\htdocs\Api\Autotask\vendor\test.php on line 35
Array
<?php
namespace ATWS\AutotaskObjects;
class Contact extends Entity
{
public $AccountID;
public $Active;
public $AdditionalAddressInformation;
public $AddressLine;
public $AddressLine1;
public $AlternatePhone;
public $City;
public $Country;
public $CountryID;
public $CreateDate;
public $EMailAddress;
public $Extension;
public $ExternalID;
public $FaxNumber;
public $FirstName;
public $LastActivityDate;
public $LastModifiedDate;
public $LastName;
public $MiddleInitial;
public $MobilePhone;
public $Note;
public $Notification;
public $Phone;
public $RoomNumber;
public $State;
public $Title;
public $ZipCode;
}

If i understand your problem you are looking for this:-
echo $json->queryResult->EntityResults->Entity->UserDefinedFields->UserDefinedField->EntityReturnInfoResults->DatabaseAction->EntityReturnInfo->EntityId;

Related

How to loop and get the values from second array in sequence

This is the Array I want to loop Into Events Index and get all the context print out of it how can i do this
Here is the Array Code Which i am trying to loop
[1] => stdClass Object
(
[id] => RPDNLNYO6U
[active] =>
[events] => Array
(
[0] => stdClass Object
(
[id] => RPDNLNYO6U_1
[created_at] => 2023-02-06T10:55:42.501003Z
[visibility] => all
[text] => Hi
[author_id] => 170bdd03-a163-49e9-4295-11fae376ff0e
)
[1] => stdClass Object
(
[id] => RPDNLNYO6U_2
[created_at] => 2023-02-06T10:55:44.102000Z
[visibility] => all
[text] => I need help
[author_id] => 170bdd03-a163-49e9-4295-11fae376ff0e
)
[2] => stdClass Object
(
[id] => RPDNLNYO6U_3
[created_at] => 2023-02-06T11:06:11.002000Z
[visibility] => agents
[type] => system_message
[text] => Chat is idle due to 10 minutes of inactivity
[system_message_type] => routing.idle
[text_vars] => stdClass Object
(
[duration] => 10
)
)
[3] => stdClass Object
(
[id] => RPDNLNYO6U_4
[created_at] => 2023-02-06T11:11:14.002000Z
[visibility] => all
[type] => system_message
[text] => Chat archived due to 15 minutes of inactivity
[system_message_type] => routing.archived_inactive
[text_vars] => stdClass Object
(
[duration] => 15
)
)
)
)
You can use a foreach loop in PHP to loop through the array and get all the context you need.
$array = [1 => (object) [
'id' => 'RPDNLNYO6U',
'active' => '',
'events' => [
(object) [
'id' => 'RPDNLNYO6U_1',
'created_at' => '2023-02-06T10:55:42.501003Z',
'visibility' => 'all',
'text' => 'Hi',
'author_id' => '170bdd03-a163-49e9-4295-11fae376ff0e'
]
]
]];
foreach ($array as $object) {
$id = $object->id;
$active = $object->active;
foreach ($object->events as $event) {
$event_id = $event->id;
$created_at = $event->created_at;
$visibility = $event->visibility;
$text = $event->text;
$author_id = $event->author_id;
echo "Event ID: $event_id, Created At: $created_at, Visibility: $visibility, Text: $text, Author ID: $author_id\n";
}
}
This will loop through the outer array and print out all the context for each event.

NetSuite: SuiteTalk: PHP: Receive item from purchase order

I am trying to create ItemReceipt which is created from PurchaseOrder. I am adding my inventory items manually in purchase order during its creation. When I am receiving this order NetSuite web service is throwing following error:
Adding new line to sublist item is not allowed.
while i have tried replaceAll attribute for ItemReceiptItemList as well.
Here is my code:
$tranDate = new \DateTime();
$tranDate = $tranDate->format('Y-m-d\TH:i:s');
$nsInventoryDetail = new InventoryDetail();
$nsInventoryAssignmentList = new InventoryAssignmentList();
$nsInventoryAssignmentList->replaceAll = true;
$nsInventoryAssignment[0] = new InventoryAssignment();
$nsInventoryAssignment[0]->receiptInventoryNumber = 3310; //NS inventory item id
$nsInventoryAssignment[0]->quantity = 1;
$nsInventoryAssignmentList->inventoryAssignment = $nsInventoryAssignment;
$nsInventoryDetail->inventoryAssignmentList = $nsInventoryAssignmentList;
$nsItemReceiptItem = new ItemReceiptItem();
$nsItemReceiptItem->item = new RecordRef();
$nsItemReceiptItem->item->internalId = 3310;
$nsItemReceiptItem->location = new RecordRef();
$nsItemReceiptItem->location->internalId = 1; // NS inventory location id
$nsItemReceiptItem->itemReceive = true;
$nsItemReceiptItem->rate = $purchasePrice->getAmount();
$nsItemReceiptItem->currency = $purchasePrice->getCurrency();
$nsItemReceiptItem->inventoryDetail = $nsInventoryDetail;
$itemList = new ItemReceiptItemList();
$itemList->item = [$nsItemReceiptItem];
$itemList->replaceAll = true;
$nsItemReceipt = new ItemReceipt();
$nsItemReceipt->createdFrom = new RecordRef();
$nsItemReceipt->createdFrom->internalId = 1223; // NS purchase order id
$nsItemReceipt->tranDate = $tranDate;
$nsItemReceipt->itemList = $itemList;
print_r($nsItemReceipt);
$nsItemReceipt = $this->itemReceiptService->create($nsItemReceipt);
Throws the following: Adding new line to sublist item is not allowed.
Following is my ItemReceipt object being sent:
NetSuite\Sdk\ItemReceipt Object
(
[createdDate] =>
[lastModifiedDate] =>
[customForm] =>
[exchangeRate] =>
[entity] =>
[currencyName] =>
[subsidiary] =>
[createdFrom] => NetSuite\Sdk\RecordRef Object
(
[internalId] => 1223
[externalId] =>
[type] => purchaseOrder
[name] =>
)
[tranDate] => 2020-01-02T13:45:36
[partner] =>
[postingPeriod] =>
[tranId] =>
[inboundShipment] =>
[memo] =>
[itemFulfillment] =>
[currency] =>
[landedCostMethod] =>
[landedCostPerLine] =>
[itemList] => NetSuite\Sdk\ItemReceiptItemList Object
(
[item] => Array
(
[0] => NetSuite\Sdk\ItemReceiptItem Object
(
[itemReceive] => 1
[jobName] =>
[item] => NetSuite\Sdk\RecordRef Object
(
[internalId] => 3310
[externalId] =>
[type] => inventoryItem
[name] =>
)
[orderLine] =>
[line] =>
[itemName] =>
[description] =>
[location] => NetSuite\Sdk\RecordRef Object
(
[internalId] => 3
[externalId] =>
[type] => location
[name] =>
)
[onHand] =>
[quantityRemaining] =>
[quantity] =>
[unitsDisplay] =>
[unitCostOverride] =>
[inventoryDetail] => NetSuite\Sdk\InventoryDetail Object
(
[inventoryAssignmentList] => NetSuite\Sdk\InventoryAssignmentList Object
(
[inventoryAssignment] => Array
(
[0] => NetSuite\Sdk\InventoryAssignment Object
(
[internalId] =>
[issueInventoryNumber] =>
[receiptInventoryNumber] =>
[binNumber] =>
[toBinNumber] =>
[quantity] => 1
[expirationDate] =>
[quantityAvailable] =>
)
)
[replaceAll] => 1
)
[customForm] =>
[nullFieldList] =>
)
[serialNumbers] =>
[binNumbers] =>
[expirationDate] =>
[rate] => 7900
[currency] => AED
[restock] =>
[billVarianceStatus] =>
[isDropShipment] =>
[options] =>
[landedCost] =>
[customFieldList] =>
)
)
[replaceAll] => 1
)
[expenseList] =>
[landedCostsList] =>
[accountingBookDetailList] =>
[customFieldList] =>
[internalId] =>
[externalId] =>
[nullFieldList] =>
)
Any help will be much appreciated.
I found this working example here
https://www.reddit.com/r/Netsuite/comments/ewlen8/suitetalk_issue_creating_itemreceipt/
-soap:Body
-
-
<q1:createdFrom internalId="35023" type="purchaseOrder"/>
-<q1:itemList>
-<q1:item>
<q1:itemReceive>true</q1:itemReceive>
<q1:item internalId="1528"/>
<q1:orderLine>1</q1:orderLine>
<q1:quantity>100</q1:quantity>
</q1:item>
</q1:itemList>
</soap:Body>
All I had to do was change $item->line to $item->orderLine and that fixed the issue - looks like you need to reference the original purchase order line number

How to get value from the given object response from Twinfield in Laravel/Lumen?

This is the response when I call the login method from twinfield API. It given the session id and cluster namespace, but the problem is how to get the value from it.
$customerApiConnector = new \PhpTwinfield\ApiConnectors\CustomerApiConnector($login);
print_r($customerApiConnector);die;
Output:
PhpTwinfield\ApiConnectors\CustomerApiConnector Object
(
[service:protected] => PhpTwinfield\Services\ProcessXmlService Object
(
[trace] => 1
[compression] => 32
[_stream_context] => Resource id #153
[_soap_version] => 1
[sdl] => Resource id #154
[__default_headers] => Array
(
[0] => SoapHeader Object
(
[namespace] => http://www.twinfield.com/
[name] => Header
[data] => Array
(
[SessionID] => f7b4c213-1a01-4c7c-87cb-7de80b1583fe
)
[mustUnderstand] =>
)
)
)
)
This is the other object.
Array
(
[1] => PhpTwinfield\CustomerAddress Object
(
[ID:PhpTwinfield\CustomerAddress:private] => 1
[type:PhpTwinfield\CustomerAddress:private] => invoice
[default:PhpTwinfield\CustomerAddress:private] => true
[name:PhpTwinfield\CustomerAddress:private] => Anand
[contact:PhpTwinfield\CustomerAddress:private] =>
[country:PhpTwinfield\CustomerAddress:private] => IN
[city:PhpTwinfield\CustomerAddress:private] => Indore
[postcode:PhpTwinfield\CustomerAddress:private] => 452001
[telephone:PhpTwinfield\CustomerAddress:private] =>
[fax:PhpTwinfield\CustomerAddress:private] =>
[email:PhpTwinfield\CustomerAddress:private] => anand#comfisoft.com
[field1:PhpTwinfield\CustomerAddress:private] =>
[field2:PhpTwinfield\CustomerAddress:private] => lig
[field4:PhpTwinfield\CustomerAddress:private] =>
[field5:PhpTwinfield\CustomerAddress:private] =>
[field6:PhpTwinfield\CustomerAddress:private] =>
)
)
Try this it will work ;)
function accessProtectedProperty($obj, $prop)
{
$reflection = new \ReflectionClass($obj);
$property = $reflection->getProperty($prop);
$property->setAccessible(true);
return json_decode($property->getValue($obj));
}

Yii cookies remember password

I create cookies authentication in action login but in another controller or another action, i call it but it just echo user'name and nothing else.
For example:
class LoginController extends Controller
{
public function actionIndex()
{
if (isset($_POST['UserLogin'])) {
$username = $_POST['UserLogin']['email'];
$password = $_POST['UserLogin']['password'];
$dataLogin = Users::model()->findByAttributes(array('email'=>$username, 'password'=>md5($password), 'role'=>1, 'status'=>1));
if($dataLogin == NULL) {
Yii::app()->user->setFlash('login_mess',Yii::t('app','Invalid email or password!'));
$this->redirect($_SERVER['HTTP_REFERER']);
}
else{
Yii::app()->session['Authentication'] = $dataLogin;
$cookies = new CHttpCookie('authentication', $dataLogin);
$cookies->expire = time() + 7*24*60*60;
Yii::app()->request->cookies['authentication'] = $cookies;
$this->redirect('/profile');
}
}
}
public function actionLogout()
{
echo "<pre>";
print_r(Yii::app()->request->cookies['authentication']);die;
echo "</pre>";
Yii::app()->session['Authentication'] = null;
$this->redirect('/');
}
}
In actionLogout i try print that cookies:
CHttpCookie Object
(
[name] => authentication
[value] => Bàn Chân Trần
[domain] =>
[expire] => 0
[path] => /
[secure] =>
[httpOnly] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
but i expect:
CHttpCookie Object
(
[name] => authentication
[value] => Users Object
(
....
[_new:CActiveRecord:private] =>
[_attributes:CActiveRecord:private] => Array
(
[id] => 4
[name] => Bàn Chân Trần
[email] => hongquan156#gmail.com
[phone_code] => +44
[phone] => 0988888888
[country] => 2
[language] => vi
[password] =>
[role] => 1
[device_token] =>
[active_key] => 9D9T7n1oWlFiRy1EJ3ULDVlBDtw4VQWT
[status] => 1
[token] =>
[payment] => 0
[created] =>
)
[_related:CActiveRecord:private] => Array
(
)
[_c:CActiveRecord:private] =>
[_pk:CActiveRecord:private] => 4
[_alias:CActiveRecord:private] => t
[_errors:CModel:private] => Array
(
)
[_validators:CModel:private] =>
[_scenario:CModel:private] => update
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
[domain] =>
[expire] => 1345801074
[path] => /
[secure] =>
[httpOnly] =>
[_e:CComponent:private] =>
[_m:CComponent:private] =>
)
How can I reslove this problem... thanks!
Since you're storing an object to cookie, you mus serialize it before storing it to cookie, and unserialize it after retrieving it :
$cookies = new CHttpCookie('authentication', serialize($dataLogin));
print_r(unserialize(Yii::app()->request->cookies['authentication']));die;

How do I extract the details from a PHP object?

I'm working with an object that returns information in a format like the following... I've removed some details where the information gets a little repetitive to save some space.
ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff5974138c9
[hash:protected] => cd2a8393493a286cf1fe97d92a947719
[productData:protected] =>
[productId:protected] => 28
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 1
[originalOrderQuantity:protected] => 0
[name:protected] => Mac Pro
[basePrice:protected] => 2799.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object (
[customerId:protected] =>
[customerGroupId:protected] =>
[discounts:protected] => Array ( )
[addresses:protected] => Array (
[4cff2f55b0fcd] => ISC_QUOTE_ADDRESS_SHIPPING Object (
[shippingMethod:protected] =>
[shippingCache:protected] =>
[handlingCost:protected] => 0
[quote:protected] => ISC_QUOTE Object *RECURSION*
[type:protected] => shipping
[id:protected] => 4cff2f55b0fcd
[firstName:protected] => asd
[lastName:protected] => asd
[company:protected] => asd
[phone:protected] => asd
[email:protected] => sz#gmail.com
[address1:protected] => asd
[address2:protected] =>
[zip:protected] => 62990
[city:protected] => asd
[state:protected] => Array (
[id] => 0
[iso2] =>
[name] => asd
)
[country:protected] => Array (
[id] => 99
[name] => India
[iso2] => IN
)
[cachedTotals:protected] => Array ( )
[customFields:protected] => Array ( )
[saveAddress:protected] =>
[customerAddressId:protected] => 0
)
[4cff2f55cc2b6] => ISC_QUOTE_ADDRESS Object (
[handlingCost:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[type:protected] => billing
[id:protected] => 4cff2f55cc2b6
[firstName:protected] => asd
[lastName:protected] => asd
[company:protected] => asd
[phone:protected] => asd
[email:protected] => sz#gmail.com
[address1:protected] => asd
[address2:protected] =>
[zip:protected] => 62990
[city:protected] => asd
[state:protected] => Array (
[id] => 0
[iso2] =>
[name] => asd
)
[country:protected] => Array (
[id] => 99
[name] => India
[iso2] => IN
)
[cachedTotals:protected] => Array ( )
[customFields:protected] => Array ( )
[saveAddress:protected] =>
[customerAddressId:protected] => 0
)
)
[coupons:protected] => Array ( )
[giftCertificates:protected] => Array ( )
[items:protected] => Array (
[0] => ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff2f55b11d2
[hash:protected] => 587e0ee453488554f782b20f3c928916
[productData:protected] =>
[productId:protected] => 24
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 3
[originalOrderQuantity:protected] => 0
[name:protected] => Apple iPod Socks
[basePrice:protected] => 29.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 1.0000
[fixedShippingCost:protected] => 0.0000
)
[1] => ISC_QUOTE_ITEM Object (
[type:protected] => 1
[id:protected] => 4cff58167d29f
[hash:protected] => 1da6aa898763172b8f7b9d8097d37f42
[productData:protected] =>
[productId:protected] => 23
[variationId:protected] => 0
[variationOptions:protected] => Array ( )
[quantity:protected] => 1
[originalOrderQuantity:protected] => 0
[name:protected] => Apple In-Ear Headphones with Remote and Mic
[basePrice:protected] => 79.0000
[sku:protected] =>
[wrapping:protected] => Array ( )
[configuration:protected] => Array ( )
[eventDate:protected] => Array ( )
[eventName:protected] =>
[parentId:protected] =>
[quote:protected] => ISC_QUOTE Object *RECURSION*
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 2.0000
[fixedShippingCost:protected] => 0.0000
)
[2] => ISC_QUOTE_ITEM Object *RECURSION*
)
[isSplitShipping:protected] =>
[cachedTotals:protected] => Array ( )
[hasFreeShipping:protected] =>
[appliedStoreCredit:protected] => 0
[appliedDiscountRules:protected] => Array ( )
[customerMessage:protected] =>
[staffNotes:protected] =>
[orderStatus:protected] => 0
[orderId:protected] =>
[discountsEnabled:protected] => 1
)
[discounts:protected] => Array ( )
[isCustomPrice:protected] =>
[addressId:protected] => 4cff2f55b0fcd
[cachedTotals:protected] => Array ( )
[inQuote:protected] => 1
[inventoryChecking:protected] => 1
[weight:protected] => 3.0000
[fixedShippingCost:protected] => 0.0000
)
I need to extract details such as ID, name, etc. so that it reads 4cff5974138c9, Mac Pro, etc. respectively. How can I do that?
You need to call a function of that class (of which ISC_QUOTE_ITEM is an object - say MyClass ) which returns the protected variable
Edit
It can be accessed. I was correct.
Like this -
Add a function inside your class MyClass if you don't already have one.
public function getName()
{
return $this->name;
}
And then in your code you can do this:-
echo $obj->getName();
Read http://php.net/manual/en/language.oop5.visibility.php for details on visibility of types of variables
You can do this by using the reflector construct:
Example taken from http://www.php.net/manual/en/reflectionclass.getproperties.php:
<?php
class Foo {
public $foo = 1;
protected $bar = 2;
private $baz = 3;
}
$foo = new Foo();
$reflect = new ReflectionClass($foo);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
foreach ($props as $prop) {
print $prop->getName() . "\n";
}
var_dump($props);
?>
As you can see also the protected $bar is returned :) And have a look at http://www.php.net/manual/en/reflectionproperty.getvalue.php#98643 there it is shown how to return the value of a protected attribute.

Categories