Piping symbol in import file is not possible ...

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205247

-- HikaShop version -- : latest
-- Joomla version -- : latest

I have a working import based on manually entered data. Now our IT department has to create a periodical export from our ERP that will be imported via a cron into our Hikashop.
They however have a problem using a piping-symbol ("|") in the column names (product_name|en-GB, product_name|fr-FR, ...)
Is there a way to change this piping-symbol so they/we can use some different character as a separator for the language-indicator?

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #205321

Hi,

I think that the easiest way will be to add a little php script which will edit the csv file in order to change the header from one value to another one.

For example in the ERP you export the file with "/\" as separator, then the php script will replace "/\" by a "|" and then the file is imported in HikaShop.

So the script must be called just before the cron import.

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205371

that might work ... how do i call a php script before the cron import?

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205384

I tried calling another php-file in the cron and then in that php file (after changing the import-file) redirect to the original url ... when I try to change the cron ... I get an "error" stating the cron assignment is set to the original url as that appears to be the correct one ... hmm ... not nice :( .
how can I solve this ... apparantly I need something els than the header-redirect-system ...

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205395

another problem arises ... when I call my php it does change the content of the file and it redirects to the cron-import BUT ... i get an error
"Could not retrieve the CSV file http://www.


.be/db/cataloog-import.csv"
If I copy-paste the url in any browser I do get the right file ... (this might be an unrelated question)

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #205374

Hi,

You can create a new massaction plugin, then set up a new mass action based on a cron trigger.
Here is the documentation to create a new mass action:
www.hikashop.com/support/documentation/6...r-documentation.html

Regarding the path issue, you have to set a server path and not an url, the path must look like "/var/www/mywebsite/myfolder/myfile.csv"

Last edit: 9 years 5 months ago by Xavier.

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205673

still a problem with the path ... I used the path as you described (applied to our system ofcourse) but I noticed something strange ...
in the error we get I noticed that the last letter is gone ... it says .../cataloog.cs instead of .../cataloog.csv ... So I tried adding a random letter and then the error states .../cataloog.csvx (with the extra character) ...

For the massaction I will have to do some more work ... get back to you on that ...

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205689

Xavier wrote: You can create a new massaction plugin, then set up a new mass action based on a cron trigger.
Here is the documentation to create a new mass action:
www.hikashop.com/support/documentation/6...r-documentation.html


I'm sorry to bother you again ... however ... I could not find anything regarding a mass action plugin on the page you linked to ... I tried to create a cron-trigger plugin but apparantly (as far as I can see) the onHikashopCronTrigger is called AFTER the normal execution of the trigger ... so my file would be updated AFTER the import is done ... that is no good ...

mass actions also don't seem to have any triggers in regards to cron triggers (I'm guessing you want me to write one of these) ...

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205726

I solved the column-title issue ... (for me at least)
I have the Export done to the file .../cataloog.csv
when the cron-job runs it checks the file .../cataloog_ok.csv (the first time this will not be found)
then I change the content of .../cataloog.csv and save the file to .../cataloog_ok.csv in the event handler after the cron-job
the next cron-job will then find the .../cataloog_ok.csv file and process it ...
There will only be a new file every day or so ... if the cron works every hour it will update the products as needed ... with a delay of about 1 hour ... that is acceptable.

Now I only need a solution for the strange filename-problem.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 5 months ago #205736

Hi,

Please paste the code giving that error, that will give us more informations about the issue.

The following user(s) said Thank You: yvo_wilms

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

  • Posts: 20
  • Thank you received: 0
9 years 5 months ago #205822

I don't know the code ... I just setup the Hikashop products cron update plugin (see image attached)
the file-box contains "/data/sites/web/wilmsbe/www/db/cataloog_import_ok.csv"

So I'm guessing the code is yours ...
The error I'm getting now is this: "Could not find the file /data/sites/web/wilmsbe/www/db/cataloog_import_ok.cs"
I hope this gets solved quickly ... pressure starts to build B)
Importing the file through the regular channels works fine and the file (extension .csV) is in the place mentioned ... somewhere the V gets dropped and then the file can not be found ...

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 5 months ago #205853

Hi,

Remove the line:
$relativePath=substr($relativePath,0,-1);
in the file plugins/hikashop/datafeed/datafeed.php and that should fix the issue.

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

  • Posts: 20
  • Thank you received: 0
9 years 4 months ago #205967

ok, I changed the code as you suggested ... now the error states:
"Could not retrieve the CSV file http://www..../cataloog_import_ok.csv" ... however, I changed all the paths leading to that file to the correct path (as mentioned above) so no URL (I think) ...
The url mentioned DOES lead to the correct file ...

I'm really puzzled now ... every problem solved uncovers another problem ... am I using the cron-jobs differently than the way it was designed?

What happens when I change the code in the plugin-file and we do an update to another version? will my change be gone or will it be taken into account in a next update?

Last edit: 9 years 4 months ago by yvo_wilms.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 4 months ago #205981

Hi,

The change I proposed has been integrated on our end for next version as this is a bug.

Please enter the relative path of the file in the setting of your plugin.
If you put the file cataloog_import_ok.csv at the root of the website, just enter cataloog_import_ok.csv in that field.

The following user(s) said Thank You: yvo_wilms

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

  • Posts: 20
  • Thank you received: 0
9 years 4 months ago #206120

DUDE ... I feel like we're going in circles ...

I entered db/cataloog_import_ok.csv and this is the error I got ...
Could not find the file /data/sites/web/wilmsbe/www/.../cataloog_import_ok.csv/
now we know why the last character was removed ...
If I change the datafeed.php back to the way it was I get
Could not retrieve the CSV file www.wilms.be/.../cataloog_import_ok.csv
...
come on ... it feels like I've been there ...
I'm sorry to come over frustrated ... I just thought it would work instantly and now I've been working on this for some days ... I know you're trying to help ...

Last edit: 9 years 1 month ago by yvo_wilms. Reason: link to the file was live ... changed the link to a non-working one.

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

  • Posts: 20
  • Thank you received: 0
9 years 4 months ago #206178

I seem to have it working ... don't really know why ...
in the datafeed.php I added

$path=$plugin->params['path'];
before
$contentFile = file_get_contents($path);
		if(empty($contentFile)){
			$messages[] = 'Could not retrieve the CSV file '. $path;
		}else{
			if(!$helper->handleContent($contentFile)){
				return false;
			}
thus going back to the original path of the file as it is entered in the settings ...
if I set the file path to db/cataloog_import_ok.csv it works ...
as I said, I'm not sure why it works but it does ... maybe now you can solve it permanently (if it makes sense to you)
Thanks for your efforts and please keep me posted on the progress of this ... issue.

Last edit: 9 years 4 months ago by yvo_wilms.

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

  • Posts: 20
  • Thank you received: 0
9 years 1 month ago #217127

I just did the update to version 2.6.0 and I got an error again stating the file could not be opened ... I now seem to have a working version of datafeed.php based on the changes I made last time ...
the main difference seems to be in the function "_getRelativePath($path)"

Attachments:

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

  • Posts: 20
  • Thank you received: 0
8 years 10 months ago #227157

Today, another update ... same problem ... same solution ... is this something that can be fixed permanently PLEASE?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 10 months ago #227191

Hi,

I am sorry but your patch is not a valid patch.
That's why that patch has not been added in HikaShop.

The variable $path is already set in the plugin

if(!empty($plugin->params['path']))
	$path=$plugin->params['path'];
else{
	$messages[] = 'No file path specified';
	return true;
}

And if that patch does not match to the regex:
if(!preg_match('#^(https?|ftp)://#',$path)){
It can be modify:
$path=$this->_getRelativePath($path);
/* ... */
$path=JURI::base().$path;
$path=str_replace('administrator','',$path);

Now you patch is just to forget all that code ; code which provide something and code which is used by other HikaShop users.
You just rewrite the variable $path and all the process made before become useless.
	$helper->header_errors = false;
	$contentFile = true;
	//-----
	$path=$plugin->params['path'];
	//$fhandle = fopen($path,"r");
	//$contentFile = fread($fhandle,filesize($path));
	//fclose($fhandle);
	$contentFile = file_get_contents($path);
	if(empty($contentFile)){

If you want an improvement in the plugin ; please ask for it.
But we can't possibly integrate your patch in HikaShop which will break the datafeed plugin in a lot of HikaShop websites.

More than that, the code in the plugin datafeed is there for the security ; to avoid using an absolute path which would be outside the Joomla website. Which avoid you targeting any file in the web server.
So, the code in the datafeed is important and would stay as it ; otherwise the plugin will become unsafe.

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.
The following user(s) said Thank You: yvo_wilms

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

  • Posts: 20
  • Thank you received: 0
8 years 10 months ago #227255

Thank you for that reply ...

I now realise my patch is not valid ... however I still have no permanent solution to my problem ...
Could you please make a patch that works for me as well as for you (and all other current users) ... or at least tell me how to use it correctly as it is ...
At this moment, if I don't do the/a patch there is no way I can get it to read the file I provide ... if I leave out the trailing / it says it can't read the file and if I put the trailing / there it says it can't find the file ...

I am willing to provide any data/information you need ... I would like it to work as designed, just like you ...

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

Time to create page: 0.082 seconds
Powered by Kunena Forum