Jump to content

bug when exporting orders to csv


Recommended Posts

In one prestashop install (but not in a different one), I couldn't export orders to csv. I tracked the issue up to a problem in classes/controller/AdminController.php

 


public function processExport($text_delimiter = '"')
{...

if (isset($params['callback']))
{
$callback_obj = (isset($params['callback_object'])) ? $params['callback_object'] : $this->context->controller;
$field_value = call_user_func_array(array($callback_obj, $params['callback']), array($field_value, $row));
}

The error came because $params['callback_object'] is not set, and $this->context->controller is not a string, and so call_user_func_array fails. I tried $this->context->controller->className instead of $this->context->controller, but in a concrete example, I found that $this->context->controller->className was 'Order' and $params['callback'] was 'setOrderCurrency', and the call to:
call_user_func_array(array($callback_obj, $params['callback']), array($field_value, $row));
took a valid price and returned an empty string, so I don't see a simple solution that I can propose at github. I don't understand how the whole callback thing works!

 

Regards!

Link to comment
Share on other sites

  • 4 weeks later...

A callback, in the context of a list (orders or customers, for instance), is a function meant to alter the display of a value. It can, for instance, replace the active/inactive value (which is either 1 or 0) by an icon. the pdf callback outputs a pdf icon.

Now, the problem, as far as csv export is concerned, is that it will receive, for most callbacks, html instead of a value. Which screws up the export because you'll have html code in your cells.

Solution is to ignore, in the processexport method, the callback param, and just output the raw value.

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...