Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » SilverStripe 3.1 SS_Report not exporting fields

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

Page: 1
Go to End
Author Topic: 126 Views
  • toddmkimball
    Avatar
    Community Member
    13 Posts

    SilverStripe 3.1 SS_Report not exporting fields Link to this post

    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

    126 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.