Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

SilverStripe 3.1 SS_Report not exporting fields


Reply


186 Views

Avatar
toddmkimball

Community Member, 13 Posts

31 January 2014 at 5:05pm

I have a basic report:

<?php
class OrdersWithLineItems extends SS_Report
{
public function title()
{
return 'Orders with Line Items';
}

public function sourceRecords($params, $sort, $limit)
{
$ordersAL = new ArrayList();

$OrderHeaders = OrderHeader::get();

foreach ($OrderHeaders as $OrderHeader) {
foreach ($OrderHeader->OrderItems() as $OrderItem) {
$tempOrderHeader = new DataObject($OrderHeader->toMap());

$tempOrderHeader->ProductCode = $OrderItem->Product()->PartNumber;
$tempOrderHeader->ProductQuantity = $OrderItem->Quantity;

$ordersAL->add($tempOrderHeader);
}
}

return $ordersAL;
}

public function columns()
{
$fields = array(
'StripeID' => array(
'title' => 'StripeID',
'link' => false
),
'OrderTotal' => array(
'title' => 'OrderTotal',
'link' => false
),
'SalesTax' => array(
'title' => 'SalesTax',
'link' => false
),
'SalesTaxCity' => array(
'title' => 'SalesTaxCity',
'link' => false
),
'SalesTaxState' => array(
'title' => 'SalesTaxState',
'link' => false
),
'SalesTaxZip' => array(
'title' => 'SalesTaxZip',
'link' => false
),
'OrderComplete' => array(
'title' => 'OrderComplete',
'link' => false
),
'Email' => array(
'title' => 'Email',
'link' => false
),
'PromoCode' => array(
'title' => 'PromoCode',
'link' => false
),
'BillingName' => array(
'title' => 'BillingName',
'link' => false
),
'BillingAddress1' => array(
'title' => 'BillingAddress1',
'link' => false
),
'BillingAddress2' => array(
'title' => 'BillingAddress2',
'link' => false
),
'BillingCity' => array(
'title' => 'BillingCity',
'link' => false
),
'BillingState' => array(
'title' => 'BillingState',
'link' => false
),
'BillingZip' => array(
'title' => 'BillingZip',
'link' => false
),
'ShippingName' => array(
'title' => 'ShippingName',
'link' => false
),
'ShippingAddress1' => array(
'title' => 'ShippingAddress1',
'link' => false
),
'ShippingAddress2' => array(
'title' => 'ShippingAddress2',
'link' => false
),
'ShippingCity' => array(
'title' => 'ShippingCity',
'link' => false
),
'ShippingState' => array(
'title' => 'ShippingState',
'link' => false
),
'ShippingZip' => array(
'title' => 'ShippingZip',
'link' => false
),
'ProductCode' => array(
'title' => 'ProductCode',
'link' => false
),
'ProductQuantity' => array(
'title' => 'ProductQuantity',
'link' => false
)
);

return $fields;
}
}

Which works as expected in the browser, but when attempting to download I only get the column headers and blank rows. The number of rows is the same number as the records that are missing, but no data. Any ideas? And I going about building this report, with related (has_many) DataObjects incorrectly?

Thanks and Regards,
Todd M. Kimball