export csv - change header

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #274826

Hi,
i would like to export every order to a csv file with the mass action - that already seems to work as it should.
Problem:
the attached system that should import the csv-file needs a specific order of the columns and specific header lines in the csv.
i suppose it should be pretty easy for hikashop to change this details of the csv file?
but i was not able to find the corresponding file or the settings for that.
thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #274830

Hello,

You can use the trigger "onBeforeOrderExport" in order to change dynamically the content during the export :
www.hikashop.com/support/documentation/6...#onBeforeOrderExport

And you can use a view override in order to change other elements during the export.
That's in the view where it will be easier to change the header ; or at least to "translate" the header names.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #275058

thanks for your reply, but its too complicated for me :)
the onBeforeOrderExport has something to do with "how to develop a hikashop plugin"!? much too complicated.
the second point sounds good to me, "override" the headers.
this should work fro me: eg. override "item1_order_product_shipping_price" with "shipping price"
but i don't know where to configure the overrides?

Please Log in or Create an account to join the conversation.

  • Posts: 81508
  • Thank you received: 13064
  • MODERATOR
6 years 8 months ago #275061

Hi,

You can override view files via the menu Display>Views.
The one you want to edit is the file "export" of the view "order".

Please Log in or Create an account to join the conversation.

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #275093

hi nicolas,
i checked the view file orders->export, but i cannot make the overrides there.
that file does only describe the logically behavior of the export process.
but where can i find the text of the header lines to override or change them?

Please Log in or Create an account to join the conversation.

  • Posts: 81508
  • Thank you received: 13064
  • MODERATOR
6 years 8 months ago #275095

Hi,

It's also there.
This code handles the display of the header:

if($maxProd && !empty($productFields)) {
		$first = array();
		$o = reset($this->orders);
		foreach($o as $key => $val) {
			if(is_array($val))
				continue;
			$first[] = $key;
		}
		$o = null;
		for($i=1;$i<=$maxProd;$i++){
			foreach($productFields as $field){
				$first[] = 'item'.$i.'_'.$field;
			}
		}
	} else {
		$first = array_keys(get_object_vars(reset($this->orders)));
	}
	$export->writeLine($first);

Please Log in or Create an account to join the conversation.

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #275613

Hi nicholas,
i am affraid, we are not talking about the same thing!?
for example, i cannot see the text "item1_order_product_name" in your code shown above!?

Please Log in or Create an account to join the conversation.

  • Posts: 81508
  • Thank you received: 13064
  • MODERATOR
6 years 8 months ago #275615

Hi,

That's because the column names are generated dynamically.
The display of the item1_order_product_name column is handled by the line of code:

$first[] = 'item'.$i.'_'.$field;
Remove that line from that file and you'll see that it will remove the itemX_YYY column names from the CSV files when you export your orders.

So I do believe that we're talking about the same thing. It's just that it is not as easy to change as you believed.

Please Log in or Create an account to join the conversation.

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #275676

ok, you are right, it is not as easy to change as i believed ..
thanks for your support i will try to get it working.

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
6 years 8 months ago #275677

Hi,

I suggest you to check component CSVimproved. You will be able to get what you want.

We use it by our selfs to export orders.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 30
  • Thank you received: 1
6 years 8 months ago #275685

thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 81508
  • Thank you received: 13064
  • MODERATOR
6 years 8 months ago #275679

Hi,

Thanks for the input. Yes, CSV improved is a great way to import/export data with HikaShop. So if you need more custom things than what HikaShop provides, it can be a life saver.

Please Log in or Create an account to join the conversation.

Time to create page: 0.089 seconds
Powered by Kunena Forum