1 <?php
2 3 4 5 6 7
8 class YMLExporter extends Controller {
9 function index() {
10 Controller::curr()->getResponse()->addHeader("Content-Type", "text/xml");
11
12
13 $rootID = array();
14 if ($startCatalogs = DataObject::get('StartCatalog')) {
15 foreach ($startCatalogs as $catalog) {
16 $rootID[$catalog->ID] = 1;
17 }
18 }
19
20 $categories = DataObject::get('Catalog', "ClassName <> 'SpecialCatalog'");
21
22 foreach($categories as $category) {
23 if (isset($rootID[$category->ParentID])) {
24 $category->ParentID = 0;
25 }
26 }
27
28 $sc = SiteConfig::current_site_config();
29 return $this->customise(array(
30 'Date' => date('Y-m-d H:m'),
31 'Name' => $sc->YMLName,
32 'Company' => $sc->YMLCompany,
33 'URL' => $sc->YMLHref,
34 'Currency' => $sc->YMLCurrency,
35 'Rate' => $sc->YMLRate,
36 'Categories' => $categories,
37 'Products' => DataObject::get('Product', ($sc->YMLAvailableOnly) ? 'Available = 1' : ''),
38 ))->renderWith('YMarketFormat');
39 }
40 }
41
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-