- $data = array(
- 'StoresHolder' => array(),
- );
- if ($this->Children()) foreach ($this->Children() as $child) {
- $newStore = array(
- "ID" => $child->ID,
- "Name" => $child->Name,
- "Address1" => $child->Address1,
- "Address2" => $child->Address2,
- "County" => $child->County,
- "News" => array(),
- "Offers" => array(),
- );
- if ($child->News()) foreach($child->News() as $news) {
- $store["News"][] = array(
- 'ID' => $news->ID,
- 'Title' => $news->Title,
- 'DatePublished' => $news->DatePublished,
- 'ExpiryDate' => $news->ExpiryDate,
- 'Body' => $news->Body,
- 'URL' => $news->URL,
- 'Photo' => $news->Photo() && $news->Photo()->exists() ? $news->Photo->Filename : false,
- );
- }
- $data['StoresHolder'][] = $newStore;
- }
- $json = Convert::array2json($data);