- Posts: 1
- Thank you received: 0
auto-import csv file every 10 minutes
Please Log in or Create an account to join the conversation.
www.hikashop.com/support/documentation/6...r-documentation.html
which explains a bit our API for plugins.
More specifically, you can define the function onHikashopCronTrigger
Then, you can call the page index.php?option=com_hikashop&ctrl=cron in
your cron scheduler every 10 minutes so that it triggers this function
of your plugin.
Finally, in that function, you can use that code:
$helper = hikashop::get('helper.import');
$contentFile = file_get_contents($feed_path);
$helper->handleContent($contentFile);
$feed_path needs to contain the absolute path to the csv file. Your
CSV will need to have its headers according to our documentation, or
you will have to add the columnNamesConversionTable parameter to the
$helper object with a conversion array like this for example:
$helper->columnNamesConversionTable = array( 'code' =>
'product_code','name' => 'product_name');
This example suppose that the product code column is called code
instead of product_code which is the name of the column in hikashop
and that the product name column is called name instead of
product_name in your CSV.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
I'm trying to setup my cron with this conversion for column headings.
Could you post a full example of a cron with this function embedded?
Thanks in advance!
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
I can't seem to get the cron to import a csv operational...
If I'm correct, you need to adapt the cron.php with the codes in this post, which I did.
Nevertheless, a server error occurs. Would you be so kind to take a look at the code I adpated to see if there are any (obvious) errors? If so, I'll send it for verifiction.
Please Log in or Create an account to join the conversation.
As I said in my previous post the code should be something like this:
class plgHikashopData_feed extends JPlugin{
function onHikashopCronTrigger(&$messages){
$helper = hikashop::get('helper.import');
$helper->columnNamesConversionTable = array( 'code' =>'product_code','name' => 'product_name');
$helper->createCategories = true;
$helper->overwrite = true;
$helper->header_errors = false;
$contentFile = file_get_contents('PATH_TO_MY_FILE');
$helper->handleContent($contentFile);
}
}
You can post your code, we'll see if we can see something wrong in it.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
Please find the code + the error:
code removed
Please Log in or Create an account to join the conversation.
Here is some information about how to create a plugin :
docs.joomla.org/Creating_a_Plugin_for_Joomla_1.5
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
thanks for the clarification.
I created a plugin (
This attachment is hidden for guests.
Please log in or register to see it.
The cron task runs without errors, but still no data is being imported.
What am I missing?
Regards,
Nikajoloem
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
Is there anything else? Do I need to change the cron url too?
Please Log in or Create an account to join the conversation.
If you trigger the cron URL manually (by loading the URL in your browser) does it trigger the plugin ?
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
This is the link: http://my_url/index2.php?option=com_hikashop&ctrl=cron
Please Log in or Create an account to join the conversation.
Add one before the class declaration like this:
echo "before loading class";
one in the class constructor and one in the cron function.
That way, when triggering the url, you will see on your browser the traces if the cron went there.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
the message appears when triggering the url. Still no import
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
Please find attached the php file.
Could you help me to put the message in the rigth place?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
Now in .zip (php-extension is not allowed...)
This attachment is hidden for guests.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.
This attachment is hidden for guests.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.
- Posts: 22
- Thank you received: 0
Curious to find out why it isn't working...
This attachment is hidden for guests.
Please log in or register to see it.
Please Log in or Create an account to join the conversation.