0

I have got the api response now i want to get only one value from the response.

I want to this value from response [progressdetails] = > array()

enter image description here

1
  • I am not sure it is possible without a loop. You have function getAllTrackings but if you are sure you want the first, you'll need to array_shift on both trackings and progressdetails. Mar 10, 2016 at 8:48

3 Answers 3

1
foreach($response as $tracking_status){

   $data = $tracking_status-> getAllData();
   print_r($data);

}

you can also used:

$response = Mage::getModel('usa/shipping_carrier_fedex')->getTracking(track_number); $trackData = $response->getAllTrackings(); $progressData = $trackData[0]->getData('progressdetail'); $deliveredStatus = $progressData[0]['activity'];

1
  • 1
    welcome :) Happy Coding
    – Ajay Patel
    Mar 11, 2016 at 9:04
0

You use the following code assuming $response contains your response:

foreach ($response->getTrackings() as $tracking)
{
    $progressDetails = $tracking->getProgressdetail();
}

If you want to get the first progress details of the first tracking you can do:

$trackings = $response->getTrackings();
if ($trackings)
{
    $firstTracking = $trackings[0];
    $progressDetails = $firstTracking->getProgressdetail();
}
2
0

Using below code

I assume $response is model here and trackings have only one item.

$response->getCollection()->getFirstItem()->getData();

Hope this will helpful.

8
  • 1
    I don't think this code will work if several trackings are being returned. Mar 10, 2016 at 8:45
  • thanks i have create cron.php But Not Give any Data Mar 10, 2016 at 8:47
  • That is correct but in question have only one trackings so i suggest this one. Mar 10, 2016 at 8:48
  • @PrashantValanda how do you know there's only one tracking ? As we can see the end of the response Mar 10, 2016 at 8:50
  • I have this code in cron.php but not give any data Mar 10, 2016 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.