Skip to main content

csv Export path (Order)

More
12 years 5 months ago #149828 by Thunder1001
Hi,
I try to use the hikashop.
But i want to auto export the order after creation.
I found the "Mass Actions" option.
There i select the a action after creation of a order for export a csv file.
If i leave the path empty the browser will push the csv as download file.

But i want to save it on serverside in a map with unique name so i can make a rotation with my erp packed to pickup and process that csv file.
How i define the path?
I tried with: c:\temp and c:\temp\ but i don't see any file.

Tom

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

More
12 years 5 months ago #149846 by nicolas
Replied by nicolas on topic csv Export path (Order)
Hi,

You need to provide the full path of the CSV file that you want.
So for example:
c:\temp\my_export.csv

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

More
12 years 5 months ago #149893 by Thunder1001
Replied by Thunder1001 on topic csv Export path (Order)
Hi,
So you need to use a fixed name for the file?
But then the file wil be override every time?
Is there any option that the system generate a randon filename, like ordernumber or customername or somthing?

Cause i want to make a import that check the directory every ... minutes for new files to import direct into our erp system.

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

More
12 years 5 months ago #149904 by nicolas
Replied by nicolas on topic csv Export path (Order)
Hi,

There is no such "dynamic" option for the csv path.

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

More
12 years 5 months ago - 12 years 5 months ago #149984 by Thunder1001
Replied by Thunder1001 on topic csv Export path (Order)
Code:
function onProcessOrderMassActionexportCsv(&$elements,&$action,$k){ $formatExport = $action['formatExport']['format']; $path = $action['formatExport']['path']; if(empty($path)){ ob_get_clean(); } $app = JFactory::getApplication(); if($app->isAdmin() || (!$app->isAdmin() && !empty($path))){ $params = new stdClass(); $params->action['order']['order_id'] = 'order_id'; unset($action['formatExport']); $params = $this->massaction->_displayResults('order',$elements,$action,$k); $params->formatExport = $formatExport; $params->path = $path; $params = $this->massaction->sortResult($params->table,$params); $this->massaction->_exportCSV($params); }

Is it not possible to edit the php code that you put a fixed path and user the hour/minute/second string .csv as filename?
Last edit: 12 years 5 months ago by Thunder1001.

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

More
12 years 5 months ago #149990 by Xavier
Replied by Xavier on topic csv Export path (Order)
Hi,

You can potentially use this kind of code:
Code:
function onProcessOrderMassActionexportCsv(&$elements,&$action,$k){ $formatExport = $action['formatExport']['format']; $path = $action['formatExport']['path']; if(empty($path)){ ob_get_clean(); } $app = JFactory::getApplication(); if($app->isAdmin() || (!$app->isAdmin() && !empty($path))){ $params = new stdClass(); $params->action['order']['order_id'] = 'order_id'; unset($action['formatExport']); $params = $this->massaction->_displayResults('order',$elements,$action,$k); $params->formatExport = $formatExport; // Added $path = str_replace('.csv','-'.date('y-m-d H:m:s').'.csv',$path); // EO Added $params->path = $path; $params = $this->massaction->sortResult($params->table,$params); $this->massaction->_exportCSV($params); } }

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

More
12 years 5 months ago #150036 by Thunder1001
Replied by Thunder1001 on topic csv Export path (Order)
Hi,
Thx allot, that's what i need :)
But a little fix for other people who need it.
use this one
Code:
$path = str_replace('.csv','-'.date('y-m-d H-m-s').'.csv',$path);
instead of
Code:
$path = str_replace('.csv','-'.date('y-m-d H:m:s').'.csv',$path);
Cause you cannot have " : " in your filename

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

More
11 years 8 months ago #186637 by wilfried
Replied by wilfried on topic csv Export path (Order)
Hello,

I am also interested to get a csv file with another name everytime I export via massaction.
After finding this solution I looked in the classes directory in the file massaction.php, but I can't find the function you are talking about.

Hope to hear from you,

Kind regards,

Wilfried


Thunder1001 wrote: Hi,
Thx allot, that's what i need :)
But a little fix for other people who need it.
use this one

Code:
$path = str_replace('.csv','-'.date('y-m-d H-m-s').'.csv',$path);
instead of
Code:
$path = str_replace('.csv','-'.date('y-m-d H:m:s').'.csv',$path);
Cause you cannot have " : " in your filename

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

More
11 years 8 months ago #186771 by korzo
Replied by korzo on topic csv Export path (Order)
For Hikashop 2.3.5 in file plugins\hikashop\massaction_order\massaction_order.php on line 302
replace
Code:
$params->path = $path;

with
Code:
$params->path = str_replace('.csv','-'.date('y-m-d H-m-s').'.csv',$path);
The following user(s) said Thank You: Xavier, wilfried

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

More
11 years 8 months ago #186900 by wilfried
Replied by wilfried on topic csv Export path (Order)
Thanks,

What should I fill in at the "export path" field?
I tried several combinations but I can't get a csv with such a filename into the directory.

Kind regards, Wilfried

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

More
11 years 8 months ago #186903 by korzo
Replied by korzo on topic csv Export path (Order)
It have to absolute path to csv file.
For example /var/www/public_html/media/com_hikashop/upload/safe/orders.csv
where /var/www/public_html is absolute path to your site.

To find your absolute path, take a look in Global Configuration, tab System. There is "Path to Log Folder ". It's absolute path to logs folder.
The following user(s) said Thank You: wilfried

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

More
11 years 8 months ago #186920 by wilfried
Replied by wilfried on topic csv Export path (Order)
I tried it with the path but without the filename. I thought that the filename was added by the new code. Now I see that the date is added to the name I fill in with the path.
So it works now.

Thanks!!!.

Kind regards, Wilfried

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

More
11 years 8 months ago #187130 by wilfried
Replied by wilfried on topic csv Export path (Order)

korzo wrote: For Hikashop 2.3.5 in file plugins\hikashop\massaction_order\massaction_order.php on line 302
replace

Code:
$params->path = $path;

with
Code:
$params->path = str_replace('.csv','-'.date('y-m-d H-m-s').'.csv',$path);


This works, but there is only one mistake. The second m that is supposed to stand for minutes should be an i
$params->path = str_replace('.csv','-'.date('y-m-d H-i-s').'.csv',$path);
The following user(s) said Thank You: Jerome

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

More
11 years 7 months ago #190181 by ltempest
Replied by ltempest on topic csv Export path (Order)
AWESOME, thanks so much. I hope the HikaShop dev team take note of this and incorporate a function in a later release to allow customisation of the CSV filename without modifying the core files.

I have one question, is it possible to include the order_number in the filename? I've tried modifying the str_replace to include the order_number variable to no avail!

Thanks

Lee

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

More
11 years 7 months ago #190199 by Xavier
Replied by Xavier on topic csv Export path (Order)
Hi,

We will add this feature in a future version of HikaShop ;)
To have the order number in the file name you need something like:
Code:
$params->path = str_replace('.csv','-'.$elements[0]->order_number.'.csv',$path);

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

More
11 years 5 months ago #196551 by denoo
Replied by denoo on topic csv Export path (Order)
Hi,

and is it also possible to get joomla username to the CSV filename?

Thanks in advance.

Denis

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

More
11 years 5 months ago #196552 by Jerome
Replied by Jerome on topic csv Export path (Order)
Hi,

In the same way that you can set the order number in the CSV file name ; you can put the username too.
But you have first to catch the Joomla username (which will be code more related to Joomla, even if you can use the function hikashop_loadUser to get the current logged user object).

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.

More
11 years 5 months ago #196609 by denoo
Replied by denoo on topic csv Export path (Order)
Hi Jerome,

not sure if I follow you correctly.

I'm using mass action export CSV after order creation, where I have order_number, username, order_product_code, order_product_quantity. So the question is if it's possible to get username from mentioned fields to use it in filename.
Can you please point me closer on some piece of code I can start with?

Thanks in advance.

Denis

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

More
11 years 5 months ago #196739 by Xavier
Replied by Xavier on topic csv Export path (Order)
Hi,

To have the username in the csv file name, you have to check the "username" checkbox in the mass action settings, then still in the file "plugins\hikashop\massaction_order\massaction_order.php" and function "onProcessOrderMassActionexportCsv()" just find the username which is present in the PHP object $elements.

It should be there: $elements[0]->username so use this in the filename.

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

More
11 years 5 months ago #196770 by denoo
Replied by denoo on topic csv Export path (Order)
Hi, Xavier

I've tried this piece of code
Code:
$params->path = str_replace('export.csv',$elements[0]->order_id.'_'.$elements[0]->order_number.'_'.$elements[0]->username.'_'.date('y-m-d_H-m-s').'.csv',$path);

Successfully got order_id, order_number, but username is missing. I have "username" checkbox checked in the mass action settings and I have username inside CSV file.

Denis

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

Time to create page: 0.761 seconds
Powered by Kunena Forum