X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Cron for Html Catalog Generation? (https://forum.x-cart.com/showthread.php?t=7287)

adpboss 04-23-2004 02:44 PM

Cron for Html Catalog Generation?
 
Anyone want to give me a starting point to set up a cron job to run the html catalog? I don't know how to call the script.

Would be a big help... :D

finestshops 05-03-2004 05:46 AM

Re: Cron for Html Catalog Generation?
 
Quote:

Originally Posted by adpboss
Anyone want to give me a starting point to set up a cron job to run the html catalog? I don't know how to call the script.

Would be a big help... :D


Here is the line we are using:

05 02 * * * cd /home/path_to_your_account/x-cart/admin; /usr/local/bin/php -q -f html_catalog.php

You'll need to comment out this line:

Code:

# require $xcart_dir."/include/security.php";

adpboss 05-03-2004 05:52 PM

Thank you Anton. You rock as usual.

NuAlpha 06-16-2004 01:46 PM

Any idea how to pass a variable from the commandline via a cronjob?

I would prefer to have an IF clause that disregards the security.php line if passed a variable instead of commenting it out.

I have tried this before, but can't seem to get it working.

Thanks!

NuAlpha 06-16-2004 01:53 PM

Also, will there be any problems if a link to the HTML catalog is already available on the main site page?

Jon 06-16-2004 06:44 PM

Perhaps make a copy of the php file, remove the security.php include, use full paths to everything, and then tuck the file below directory root?

NuAlpha 06-24-2004 08:48 AM

Tried using 27stars post but I soon discovered it wasn't actually creating the catalog, but merely loading the page. Learned this from trying to run the HTML catalog script from the commandline...all that happened was that the html code for that page loaded. So I adapted the code a little and here is what we are using.

Replaced:
Code:

require $xcart_dir."/include/security.php";

With:
Code:

if ($_SERVER['argv'][1] != 'CatalogCron')
        require $xcart_dir."/include/security.php";
else {
        $REQUEST_METHOD = 'POST';
        $mode = 'catalog_gen';
        $namestyle = 'hyphen';
        $process_subcats = 'checked';
        $pages_per_pass = 0;
        $gen_action = 3;
}


Use the cron (or something similar):
Code:

05 02 * * * cd /home/path_to_your_account/x-cart/admin; /usr/local/bin/php -q -f html_catalog.php CatalogCron

Please note that your PHP setup must have argv registered. If it doesn't, you can add php_value register_argc_argv 1 to your .htaccess file to enable it.

finestshops 06-24-2004 11:11 AM

Quote:

Originally Posted by NuAlpha
Tried using 27stars post but I soon discovered it wasn't actually creating the catalog, but merely loading the page.


:oops: Sorry, forgot to mention you have to remove a couple of "if" statements and rename the script to use it as cron - we use a custom cron generator to put pages in root.
but your solution looks good. I did see the code for auto identification of script running in shell, so you do not have to pass any variables at all. If you need it, try to search for cron db_backup.php in this forum.

NuAlpha 06-24-2004 05:38 PM

8O For some reason the HTML catalog is creating hundreds of sessionids. We are at 790 and climbing rapidly. I do not know if this is from running it as a cronjob or what.

Anyone else experienced this?? :-k

adpboss 08-17-2004 09:10 PM

For anyone that is interested, Garry from X-Cart Plus whipped me up some 3.4 and 3.5 HTML Cron Scripts that are a dream to setup and run. He charged a fair price for something that makes your life much easier.

You can PM GarryHS here.

garryhs 08-18-2004 01:44 AM

Cron Job to Run Catalog
 
Hi all,

Yes, if you are after a Cron Script to Produce your Catalog in either 3.4.x or 3.5.x then just email me at enquiries@x-cart-plus.com

Thanks for the positive feedback Adpboss.

finestshops 10-09-2004 03:34 PM

Just an update.
To setup cron job in v4 (and this will work in v35):

in html_catalog.php

Replaced:

Code:

  require $xcart_dir."/include/security.php";

With:

Code:

if ($_SERVER[DOCUMENT_ROOT]) {
  #
  #  Running from the web, make sure we authenticate the user
  #
    require $xcart_dir."/include/security.php";
} else {
  #
  #  Running from command line
  #
  $command_line_mode = true;
  ini_set('html_errors', '0');
  $REQUEST_METHOD = 'POST';
  $start_category = '';
  $mode = 'catalog_gen';
  $namestyle = 'hyphen_4';
  $process_subcats = 'checked';
  $pages_per_pass = 0;
  $gen_action = 3;
  $process_staticpages = 'checked';
  $lngcat[US] = '/..';
}


Cron job will be:

Code:

05 02 * * * cd /home/path_to_your_account/x-cart/admin; /usr/local/bin/php -q -f html_catalog.php 

CC 04-30-2005 11:34 AM

Sorry to bring up an old post, but if you are running the cronjob from a none Command Line setup, how would you run this?

We run from a plesk server which is not a command line setup of php, so we cant run this as one.
We have tried running through Lynx like this:

Code:

/usr/local/bin/lynx -dump http://www.xxxxxx.com/admin/html_catalog.php

But we are then confronted with the error that Lynx does not have access to the file, as lynx is in effect only a browser itself.
Is there anyway we can add code to allow access to Lynx?
Or anyway to dump the command if not by command line?

Many thanks.

mffowler 04-30-2005 11:51 PM

I setup the cron job in cPanel and it does work when I just tested it on a line command, BUT, it generates the catalog at root level. The problem is that I need to generate it in the catalog as I have many stores in root level directories.

I have replaced the code as 27stars mentioned and the DIR CATALOG still is the same:

Code:

    require $xcart_dir."/include/security.php";
} else {
  #
  #  Running from command line
  #
  $command_line_mode = true;
  ini_set('html_errors', '0');
  $REQUEST_METHOD = 'POST';
  $start_category = '';
  $mode = 'catalog_gen';
  $namestyle = 'hyphen_4';
  $process_subcats = 'checked';
  $pages_per_pass = 0;
  $gen_action = 3;
  $process_staticpages = 'checked';
  $lngcat[US] = '/..';
}

$location[] = array(func_get_langvar_by_name("lbl_html_catalog"), "");

define ('DIR_CATALOG', '/catalog');

So, why would this generate in root vs. in my store/catalog as the DIR CATALOG location says?

Thanks for your assistance!

- Mike

mffowler 06-04-2005 07:22 PM

OK, this problem was fixed by putting a bash script at server root (below public_html):
Create a file with the correct paths and call it html_catalog.sh
Code:

cd /home/your/path/to/admin
/usr/local/bin/php -q -f html_catalog.php
mv /home/user_account_here/public_html/*.html /home/user_account_here/public_html/dir_for_store/

Now you just need to create the cron job. In cPanel this is easy: Cron jobs/Advanced (UNIX Style)

Enter the time to run the job and the script: /bin/sh /home/user_account_here/html_catalog.sh

Now, html catalog is created automatically at whatever time you choose. The previous posts create the modification in the html_catalog.php and this just moves the files from root to the dir. of the store. If you want them in root, that's OK, just skip the bash script. - Mike

DanUK 12-05-2005 05:40 AM

27stars last bit of code from Oct 9 2004 works for me up to a point (!) but my html_catalog.php won't recognise:

Code:

if ($_SERVER[DOCUMENT_ROOT]) {

..it's a blank if I debug so it goes straight to the catalog generation from the admin section i.e. command line mode. Any ideas why this might be?

Thanks

Dan

Jon 12-05-2005 07:58 AM

It's probably getting killed by X-Cart "security."

Instead try the less secure: $DOCUMENT_ROOT

nfc5382 04-23-2006 12:57 PM

seems to work for a little bit, but eventually dies? even when I try to generate the catalog through the xcart admin the same happens....

% php -q -f html_catalog.php
Generating catalog

Converting pages to HTML
./catalog/index.html

./catalog/ATV-p-1-c-195.html

./catalog/ATV_Accessories-p-1-c-200.html

./catalog/ATV_Accessories-p-2-c-200.html

./catalog/Horn_Kit_ATV-p-16511.html

./catalog/ATV_Whip-p-16530.html

./catalog/Lighted_ATV_Whip-p-16531.html

./catalog/NGK_SPARK_PLUGS_BOX_OF_10-p-16744.html

./catalog/TIE_DOWNS_HEAVY_DUTY-p-17338.html

./catalog/Tire_Chains_REAR_EIGER___VINSON-p-17760.html

./catalog/ATV_Gun_Boot-p-17761.html

./catalog/GUN_BOOT_MOUNTING_BRACKET-p-17762.html

./catalog/ATV_QuadSport_Z400-p-1-c-210.html

Killed

B00MER 04-26-2006 07:37 AM

:arrow: Moved to Custom Mods.

Skateboards.com 08-18-2006 01:55 PM

All this is good but..
 
Quote:

Originally Posted by mffowler
OK, this problem was fixed by putting a bash script at server root (below public_html):
Create a file with the correct paths and call it html_catalog.sh
Code:

cd /home/your/path/to/admin
/usr/local/bin/php -q -f html_catalog.php
mv /home/user_account_here/public_html/*.html /home/user_account_here/public_html/dir_for_store/

Now you just need to create the cron job. In cPanel this is easy: Cron jobs/Advanced (UNIX Style)

Enter the time to run the job and the script: /bin/sh /home/user_account_here/html_catalog.sh

Now, html catalog is created automatically at whatever time you choose. The previous posts create the modification in the html_catalog.php and this just moves the files from root to the dir. of the store. If you want them in root, that's OK, just skip the bash script. - Mike





I need my index.html to stay put in my docroot so my initial splash page will come up. I tried the code mentioned above and the generation works great but I really need a way to drop this automatically into my store/catalog dir....

My html_catalog.php reads like this:

Code:

# require $xcart_dir."/include/security.php";


##########################
# CATALOG SCHEDULER CODE
##########################

if ($_SERVER[DOCUMENT_ROOT]) {
  #
  #  Running from the web, make sure we authenticate the user
  #
    require $xcart_dir."/include/security.php";
} else {
  #
  #  Running from command line
  #
  $command_line_mode = true;
  ini_set('html_errors', '0');
  $REQUEST_METHOD = 'POST';
  $start_category = '';
  $mode = 'catalog_gen';
  $namestyle = 'hyphen_4';
  $process_subcats = 'checked';
  $pages_per_pass = 0;
  $gen_action = 3;
  $process_staticpages = 'checked';
  $lngcat[US] = '/..';
}

$location[] = array(func_get_langvar_by_name("lbl_html_catalog"), "");

define ('DIR_CATALOG', '/catalog');
##########################


B00MER 08-18-2006 04:40 PM

Re: All this is good but..
 
Quote:

Originally Posted by Skateboards.com
I need my index.html to stay put in my docroot so my initial splash page will come up. I tried the code mentioned above and the generation works great but I really need a way to drop this automatically into my store/catalog dir....


Your best bet is to just have your entire catalog generated on the root of public_html/ or what not. It's really an SEO thing since, /shop/xcart/catalog/file.html will rank lower than just /file.html since its closer to the root homepage. :wink:


All times are GMT -8. The time now is 08:49 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.