function organizeExportColumn($data,$table,&$elements,&$action,&$types){
switch($data){
case 'product':
switch($table){
case 'product':
$ids = array();
$database = JFactory::getDBO();
foreach($elements as $element){
if(isset($element->product_parent_id->id)){
$ids[] = $element->product_parent_id->id;
}else if($element->product_parent_id){
$ids[] = $element->product_parent_id;
}
}
if(!empty($ids)){
$tIds = array();
foreach($ids as $id){
if(isset($id->id))
$tIds[(int)$id->id] = (int)$id->id;
elseif($id != 0)
$tIds[(int)$id] = (int)$id;
}
if(empty($tIds))
$tIds = array(0);
$query = 'SELECT product_id, product_code';
$query .= ' FROM '.hikashop_table('product');
$query .= ' WHERE product_id IN ('.implode(',',$tIds).')';
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach($elements as &$element){
$id = $element->product_parent_id;
$element->product_parent_id = '';
if(!isset($types['product_parent_id']))
$types['product_parent_id'] = new stdClass();
$types['product_parent_id']->type = 'text';
foreach($rows as $row){
if(isset($id->id) && $id->id != $row->product_id){continue;}
$element->product_parent_id = $row->product_code;
}
unset($element);
}
}
break;
case 'related':
$ids = array();
$database = JFactory::getDBO();
foreach($elements as $element){
$ids[] = $element->product_id;
}
$query = 'SELECT pr.product_id, p.product_code';
$query .= ' FROM '.hikashop_table('product').' AS p';
$query .= ' INNER JOIN '.hikashop_table('product_related').' AS pr ON pr.product_related_id = p.product_id';
$query .= ' WHERE pr.product_id IN ('.implode(',',$ids).')';
$database->setQuery($query);
$rows = $database->loadObjectList();
$types['related']->type = 'text';
foreach($elements as $element){
foreach($element as $key=>$related){
if($key == 'related'){
foreach($related as $product){
$product->related = '';
foreach($rows as $row){
if($element->product_id != $row->product_id){continue;}
$product->related = $row->product_code;
}
}
}
}
}
break;
case 'category':
unset($action['category']);
$database = JFactory::getDBO();
$ids = array();
foreach($elements as $element){
foreach($element as $key=>$data){
if($key == 'category'){
foreach($data as $category){
if(isset($category->category_id)){
$ids[] = (int)$category->category_id;
}
}
}
}
}
if(!empty($ids)){
$query = 'SELECT DISTINCT category_name, category_id';
$query .= ' FROM '.hikashop_table('category');
$query .= ' WHERE category_id IN ('.implode(',',$ids).')';
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach($elements as $element){
foreach($element as $key=>&$data){
if($key == 'category'){
foreach($data as &$category){
if(isset($category->category_id)){
$array = array();
foreach($rows as $row){
if($row->category_id == $category->category_id){
$array[] = $row->category_name;
}
}
$category->categories = $this->separator($array,$data,$table);
$types['categories'] = new stdClass();
$types['categories']->type = 'text';
$action['category']['categories'] = 'categories';
}
unset($category);
}
}
unset($data);
}
}
}
break;
}
break;
case 'user':
switch($table){
case 'address':
foreach($elements as &$element){
if(!isset($element->address)){continue;}
foreach($element->address as $k=>$address){
if($address->address_default != 1){
unset($element->address[$k]);
}
}
unset($element);
}
break;
}
break;
case 'category':
//unset($action['category']);
$database = JFactory::getDBO();
$ids = array();
foreach($elements as $category){
if(isset($category->category_id)){
$ids[] = (int)$category->category_id;
}
if(isset($category->category_parent_id)){
$ids[] = (int)$category->category_parent_id->id;
}
}
if(!empty($ids)){
$query = 'SELECT DISTINCT category_name, category_id';
$query .= ' FROM '.hikashop_table('category');
$query .= ' WHERE category_id IN ('.implode(',',$ids).')';
$database->setQuery($query);
$rows = $database->loadObjectList();
foreach($elements as &$category){
if(isset($category->category_parent_id->id)){
$array = array();
foreach($rows as $row){
if($row->category_id == $category->category_parent_id->id){
$array[] = $row->category_name;
}
}
$category->parent_category = $this->separator($array,$data,$table);
if(!isset($types['parent_category']) || !is_object($types['parent_category']))
$types['parent_category'] = new stdClass();
$types['parent_category']->type = 'text';
$action['category']['parent_category'] = 'parent_category';
}
if(isset($category->category_id)){
$array = array();
foreach($rows as $row){
if($row->category_id == $category->category_id){
$array[] = $row->category_name;
}
}
$category->categories = $this->separator($array,$data,$table);
if(!isset($types['categories']) || !is_object($types['categories']))
$types['categories'] = new stdClass();
$types['categories']->type = 'text';
//$action['category']['categories'] = 'categories';
}
unset($category);
}
}
break;
case 'order':
switch($table){
case 'address':
if(isset($action['address'])){
foreach($elements as &$element){
$element->shipping_address = array();
$element->billing_address = array();
if(!isset($element->address)){continue;}
foreach($element->address as $address){
if($address->address_id === $element->order_shipping_address_id || $address->address_id === $element->order_billing_address_id){
// Reverse the order of these elements to have the shipping address first
if(!isset($action['shipping_address'])) $action['shipping_address'] = array();
if(!isset($action['billing_address'])) $action['billing_address'] = array();
}
if($address->address_id === $element->order_shipping_address_id && $address->address_id === $element->order_billing_address_id){
$object = new stdClass();
foreach($address as $column=>$value){
if(!isset($action['address'][$column])){continue;}
$billing_column = 'billing_'.$column;
$action['billing_address'][$billing_column] = $billing_column;
$object->$billing_column=$value;
if(!isset($types[$billing_column])) $types[$billing_column] = new stdClass();
$types[$billing_column]->type = $types[$column]->type;
$shipping_column = 'shipping_'.$column;
$action['shipping_address'][$shipping_column] = $shipping_column;
$object->$shipping_column=$value;
if(!isset($types[$shipping_column])) $types[$shipping_column] = new stdClass();
$types[$shipping_column]->type = $types[$column]->type;
}
$element->billing_address[] = $object;
$element->shipping_address[] = $object;
}else if($address->address_id === $element->order_shipping_address_id){
$object = new stdClass();
foreach($address as $column=>$value){
if(!isset($action['address'][$column])){continue;}
$shipping_column = 'shipping_'.$column;
$action['shipping_address'][$shipping_column] = $shipping_column;
$object->$shipping_column=$value;
if(!isset($types[$shipping_column])) $types[$shipping_column] = new stdClass();
$types[$shipping_column]->type = $types[$column]->type;
}
$element->shipping_address[] = $object;
}else if($address->address_id === $element->order_billing_address_id){
$object = new stdClass();
foreach($address as $column=>$value){
if(!isset($action['address'][$column])){continue;}
$billing_column = 'billing_'.$column;
$action['billing_address'][$billing_column] = $billing_column;
$object->$billing_column = $value;
if(!isset($types[$billing_column])) $types[$billing_column] = new stdClass();
$types[$billing_column]->type = $types[$column]->type;
}
$element->billing_address[] = $object;
}
}
unset($element);
}
unset($action['address']);
}
break;
case 'order_product':
if(isset($action['order_product'])){
foreach($elements as &$element){
$cpt = 1;
if(!isset($element->order_product)){continue;}
if(!isset($element->order_full_tax)){
$element->order_full_tax = new stdClass();
$element->order_full_tax->value = 0;
// $action['order']['order_full_tax'] = 'order_full_tax';
$types['order_full_tax'] = new stdClass();
$types['order_full_tax']->type = 'price';
}
if(!isset($element->order_shipping_tax->value)){
$tmpValue = (int)$element->order_shipping_tax;
$element->order_shipping_tax = new stdClass();
$element->order_shipping_tax->value = $tmpValue;
}
if(!isset($element->order_discount_tax->value)){
$tmpValue = (int)$element->order_discount_tax;
$element->order_discount_tax = new stdClass();
$element->order_discount_tax->value = $tmpValue;
}
$element->order_full_tax->value += (int)$element->order_shipping_tax->value - (int)$element->order_discount_tax->value;
$element->order_full_tax->currency = $element->order_currency_id;
foreach($element->order_product as $product){
if(isset($product->order_product_quantity) && isset($product->order_product_tax)){
$element->order_full_tax->value+=round($product->order_product_quantity*$product->order_product_tax,2);
}
$tablename = 'product'.$cpt;
$object = new stdClass();
foreach($product as $column=>$value){
if(!isset($action['order_product'][$column])){continue;}
$product_column = 'item'.$cpt.'_'.$column;
if(!isset($action[$tablename]))
$action[$tablename] = new stdClass();
$action[$tablename]->$product_column = $product_column;
$object->$product_column = $value;
$types[$product_column] = new stdClass();
if(isset($types[$column]->type)){
$types[$product_column]->type = $types[$column]->type;
}else{
$types[$product_column]->type = '';
}
}
$element->$tablename = array($object);
$cpt++;
}
unset($element);
}
unset($action['order_product']);
}
break;
case 'joomla_users':
if(isset($action['joomla_users']) && isset($elements[0]->joomla_users)){
foreach($elements as $element){
foreach($element->joomla_users as $joomla_users){
foreach($joomla_users as $column=>$value){
$types[$column] = new stdClass();
if(!isset($types[$column]->type)){
$types[$column]->type = '';
}
}
}
}
}
break;
}
break;
}
}
If that is not solving your issue, a backend and a FTP access will be required, you can send them via our contact form, don't forget to give the url of that topic in the message.