1. $data = array(
  2. 'StoresHolder' => array(),
  3. );
  4. if ($this->Children()) foreach ($this->Children() as $child) {
  5. $newStore = array(
  6. "ID" => $child->ID,
  7. "Name" => $child->Name,
  8. "Address1" => $child->Address1,
  9. "Address2" => $child->Address2,
  10. "County" => $child->County,
  11. "News" => array(),
  12. "Offers" => array(),
  13. );
  14. if ($child->News()) foreach($child->News() as $news) {
  15. $store["News"][] = array(
  16. 'ID' => $news->ID,
  17. 'Title' => $news->Title,
  18. 'DatePublished' => $news->DatePublished,
  19. 'ExpiryDate' => $news->ExpiryDate,
  20. 'Body' => $news->Body,
  21. 'URL' => $news->URL,
  22. 'Photo' => $news->Photo() && $news->Photo()->exists() ? $news->Photo->Filename : false,
  23. );
  24. }
  25. $data['StoresHolder'][] = $newStore;
  26. }
  27. $json = Convert::array2json($data);