Delete all product and import new from cvs

  • Posts: 20
  • Thank you received: 1
7 years 8 months ago #247332

-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.6.0
-- Browser(s) name and version -- : firefox

Hi, i've this operation to do on hickashop every night at 3:00 am.

1) Delete all product in the db but leave the images in /upload folder
2) import new product from csv at 3.00 am

How i can do that?

So for the first operation i' think that i've to
1a) export actual product in csv file using mass action
1b) delete actual product using cvs file how filter with mass action

2) import cvs using mass import...

But in both the case how i can specify a precise time to execute the script? becouse actually the triggers permit only every day, every hour, every minute.
And second i don't want to eliminate images when a product is deleted.. how i can do it?

Thanks

Last edit: 7 years 8 months ago by parsifaltheking.

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 8 months ago #247335

Hi,

I would recommend to use the HikaShop Products cron update plugin that you can configure via the Joomla plugins manager instead of using mass actions.
It is made to do exactly what you want.
It can import the products from a CSV periodically, and using the last cron update setting of the plugin, you can have it run at the hour you want.
And there is also a "delete products not in the CSV" setting to remove only the products not listed in the CSV. That's way, it's less resource intensive, and it can also delete the images of the products it deletes since they won't be used anymore.

You canr ead more about it here:
www.hikashop.com/support/documentation/7...hop-import.html#cron

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

  • Posts: 20
  • Thank you received: 1
7 years 8 months ago #247451

Ok but i want that when the products not listed in csv are deleted i don't want that the correspondents images are deleted because from a few days it can be republished.
I've view that cron tab are scheduling at 15, 30, 60 min but if i want that that the import is execute only at 3:00 am at every day how i can do?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 8 months ago #247479

Hi,

1. Then you'll have to modify the delete function of the file administrator/components/com_hikashop/classes/product.php to remove the part which removes the unecessary images.

2. You set the cron tab scheduling to every 10 minutes for example. Then, you set the last cron update setting of the plugin to yesterday at 3 am with a frequency of 1 day. And thus, it will check every 10 minutes wether the delay between "now" and the "last cron update" is greater than 1 day or not. If it's not, it won't do anything. If it is, it will run the import and reset the last cron update setting to "now".

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

  • Posts: 20
  • Thank you received: 1
7 years 8 months ago #247525

Ok, i've configured cron plugin and start but i've the error:

Could not retrieve the CSV file www.xxxx.it/web/images/com_hikashop/upload/test.csv

But if i insert the path in browser i can download the csv file. what is wrong?
in the plugin File field there is:
www.xxxx.it/web/images/com_hikashop/upload/test.csv

and the permission of the file is the same of website infact the photo is correctly load.

Last edit: 7 years 8 months ago by parsifaltheking.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
7 years 8 months ago #247527

Hi,

In the configuration, please specify a relative path instead of an URL.
Regarding the URL you put, I don't think it's a working URL ; I guess that "web" folder is the root of your website and it should not be visible in the URL.

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: 20
  • Thank you received: 1
7 years 8 months ago #247540

I've tested but not work.
Can you give me a working example of the path?
The web is subdirectory in witch i've installed the site; the upload folder is the default folder of hikashop to load product images; another server upload the file in this directory and i' want to import in hikashop.

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 8 months ago #247547

Hi,

If you have the error "Could not retrieve the CSV file www.xxxx.it/web/images/com_hikashop/upload/test.csv "
In means that PHP on your website is not allowed to download the file www.xxxx.it/web/images/com_hikashop/upload/test.csv
First, make sure that you have http : // at the beginning of the file if it's a URL.
Second, here is what the PHP documentations says about such potential problem:

If PHP has decided that filename specifies a local file, then it will try to open a stream on that file. The file must be accessible to PHP, so you need to ensure that the file access permissions allow this access. If you have enabled safe mode or open_basedir further restrictions may apply.

If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.

So, in simple terms:
If you enter a URL, you must have allow_url_fopen turned on in your php.ini
If you enter a path, the access rights on the file must allow the user of your apache server to access the file, and if open_basedir is activated on your server, the file must be in a folder of your open_basedir setting.
So you need to check on all that with your system administrator or hosting company. HikaShop has no control over all that, it just asks PHP to open the file with the path that you see in the error message. If it's refused, either the path is wrong, or there is a problem with the configuration of the server.

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

  • Posts: 20
  • Thank you received: 1
7 years 8 months ago #248177

I've resolved the problem..thank's to your information

My hosting provider disable the function fopen, so i've modify php.ini and add:

allow_url_fopen=On

and now it works.

How i can close the topic?

The following user(s) said Thank You: Mohamed Thelji

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

  • Posts: 12953
  • Thank you received: 1778
7 years 8 months ago #248179

Hello,

I just closed it.

Thank you for your feedback

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

  • Posts: 20
  • Thank you received: 1
7 years 7 months ago #248515

Sorry for the question.. only one thing:

when cron plugin work every 60 minutes, if the time passed is more than 24 hour it import the file data; but it import every time that it can be execute or only the first one?
If the file change only at 3.00 am every night and the system read it at 3.20 am; after the first time in witch import new products and delete the product that aren't in the file; it do nothig or it import again all product?

Thanks

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 7 months ago #248530

Hi,

If you set a frequency of 1 day in the plugin, it will do the import once a day. The frequency at which the plugin is triggered so that it can check if it needs to run the import or not depends on the settings in your cron tab of the HikaShop configuration.
So it's good to have a low frequency in the cron tab of the HikaShop configuration and the frequency you want in the settings of the plugin.

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

  • Posts: 20
  • Thank you received: 1
7 years 5 months ago #254376

I've more problem with the import from cvs because it work not at the correct time.

I want that at 3:00 am the system import cvs file and update products.. so i've use this settings:

HIKASHOP -> GLOBAL CONFIG->CRON
delay from two cron : 15 min

modify your cron:
activated: yes
frequency: 15 min.
( in the log i've this error:
Strict Standards: Only variables should be passed by reference in /var/www/vhosts/xxxxxxghi.it/httpdocs/web/administrator/components/com_hikashop/helpers/import.php on line 595 )

Send email if only hikashop do an action

In CRON PLUGIN i have:

Frequency: 86400
Last update: 1477828800 ( converted timestamp is: 10/30/2016 @ 12:00pm (UTC) ) ( i've do some test to find correct value but not work)

So with this parameters the cron import at 17:10 pm and not at 3:00 am ( at me the email arrives at 18:10 because thereis server timezone i think).

So what is my error that i can't import it at 3:00 am every night??

Thanks.

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 5 months ago #254435

Hi,

If the email arrives à 18h10, then it means that your timestamp has to be shifted by +9 hours if you want the cron to run at 3am.
Also note that if the "last update" timestamp you set if further in the past, it will run immediately.
So for example, if you configure your plugin around 18:00 and that you set a last update timestamp to yesterday at 03:00, the plugin will run immediately when the next cron is launched (every 15 minutes) because today 03:00 is already in the past.
So that probably explains why you're getting that.

Last edit: 7 years 5 months ago by nicolas.

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

  • Posts: 20
  • Thank you received: 1
7 years 4 months ago #257528

Hi, i've set the plugin with this data:
FREQUENCY 86400
LAST UPDATE: 1482742800 ( 26/12/2016 - 9 AM)

And CRON Set with:
Delay from two cron: 15 min

BUT THE CRON IS EXECUTE AT DIFFERENT TIME:

12/12/2016 - 11:24
11/12/2016 - 11:09
10/12/2016 - 10:54
09/12/2016 - 10:54
08/12/2016 - 10:54
07/12/2016 - 10:39
06/12/2016 - 10:24
05/12/2016 - 10:09
04/12/2016 - 10:09
03/12/2016 - 9:55
02/12/2016 - 9:39
01/12/2016 - 9:24

WHAT IS THE ERROR? I Want that the import is enable every daty at 3:00 am..but not work..

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 4 months ago #257534

Hi,

Then you should configure your cron task to run every minute in your configuration of HikaShop and have your cron task triggered on your own server.
That way, you'll only get a 1 minute gap instead of 15 minutes when the last cron date isn't updated fast enough.
Also, change the last cron timestamp to today 3 am instead of today (or yesterday) 9am and the next time it will trigger will be tomorrow at 3 am.
You can use that website to convert the date you want into a unix timestamp (and vice-versa):
www.4webhelp.net/us/timestamp.php

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

  • Posts: 20
  • Thank you received: 1
7 years 4 months ago #257853

Ok, in Cron i've set delay from two cron 1min but the min frequency in Web Cron Your Cron Task is 15 min..
how i can change it?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 4 months ago #257855

Hi,

The web cron system can only be reduced to 15 minutes. If you want more frequency, you need to setup your own cron on your server (or with a 3rd party cron service):
www.hikashop.com/support/documentation/5...ron-task.html#server

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

  • Posts: 20
  • Thank you received: 1
7 years 3 months ago #258868

Ok but if i want that the cron job is execute one time every day at example at 4:00 and nothing check every x minutes how i can do?
Is possible ?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
7 years 3 months ago #258872

Hi,

Sure.
Setup your HikaShop cron task to be triggered every minute, and change the last update setting of the plugin to the timestamp of tomorrow 4am and the frequency to 1 day in seconds.

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

Time to create page: 0.109 seconds
Powered by Kunena Forum