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)
-   -   Generate Product HTML on Modify [3.5.x] (https://forum.x-cart.com/showthread.php?t=9015)

B00MER 08-20-2004 11:33 PM

Generate Product HTML on Modify [3.5.x]
 
Here's a mod I did on cart-lab.com, I was sick of re-updating the product html every time I made a change to my products. It works in a sense that it will update the product's html counter part, however all subsequent pages, like index.html and related product(s), etc. Wont be generated, so you end up having to regenerate the html catalog again. If anyone wants to take it a step further into 4.0.x perhaps and add the missing features to make it complete feel free.

admin/html_catalog.php after:
Code:

func_html_location("html_catalog.php",30);
add the following:
Code:

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Generate HTML after file modify/add product mod by cart-lab.com
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        } elseif($REQUEST_METHOD=="GET" && $mode=="gen") {

        # no name style defined use underscore by default
  $namestyle = $namestyle ? true : "hyphen";

        # stripped down version of original my_save_data function
        function save_data_nooutput($filename, $data) {
                global $hc_state, $count;
                $fp = fopen($filename, "w+");
                if (!$fp) {
                        echo "<font color=red>Cannot save file: ".$filename."</font>";
                        x_session_save();
                        exit;
                }
                fwrite($fp, $data);
                $count++;
        }

  # naming convientions
        if ($namestyle == "hyphen") {
                $hc_state["product_namestyle"] = "{product_name}-p-{productid}.html";
        }        elseif ($namestyle == "new") {
                $hc_state["product_namestyle"] = "{product_name}_p_{productid}.html";
        }        else {
                $hc_state["product_namestyle"] = "product_{productid}_{product_name}.html";
        }

        if($productid) {

                #list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/home.php", "");
                #$page_src = process_page($page_src);
                #save_data_nooutput("$cat_dir/index.html", $page_src);
               
                $product_data = func_query("SELECT product, productid, categoryid, categoryid1, categoryid2, categoryid3 FROM $sql_tbl[products] WHERE productid=$productid");
                list($http_headers, $page_src) = func_http_get_request($site_location["host"].":".$site_location["port"], $site_location["path"].DIR_CUSTOMER."/product.php", "productid=$productid");
                $page_src = process_page($page_src);
                $page_name = product_filename($product_data[0]["productid"], $product_data[0]["product"]);
                save_data_nooutput("$cat_dir/$page_name", $page_src);               
               
                $smarty->assign("main","product_modify_message");
          @include $xcart_dir."/modules/gold_display.php";
          $smarty->display("admin/home.tpl");
        }
       
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Next edit include/product_modify.php and find the code segment:
Code:

        } else {
#
# Form filled with errors
#


Paste the following above it

Code:

# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Generate HTML after file modify/add product mod by cart-lab.com
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=       
        func_header_location("..".DIR_ADMIN."/html_catalog.php?mode=gen&productid=$productid");
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


jeeya 08-21-2004 12:12 AM

This is Excellent Mod. This way I won't have to generate whole 1500 product catalgo just for one single product modification!

Will this work in 3.4.0
thanks

B00MER 08-21-2004 08:59 AM

It *MAY* work in 3.4.x all you should need to change is the "..".DIR_ADMIN."/html_catalog.php to "../admin/html_catalog.php

POSDepot 08-24-2004 12:06 PM

I get this error after saving a product:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home2/softsell/pointofsaledepot-www/store/include/func.php on line 2801

Warning: fsockopen(): unable to connect to www.pointofsaledepot.com::80 in /home2/softsell/pointofsaledepot-www/store/include/func.php on line 2801

It then creates a 0 byte html file.

Any ideas?

Thanks
Randy

B00MER 08-24-2004 01:45 PM

Generating the HTML cat regularly generate any errors?

POSDepot 08-24-2004 02:15 PM

nope .. just after I edit a product.

jeeya 08-28-2004 11:31 PM

I tried in and after modifying when I clicked submit button, on next page header it gave following error. And html catalog part for that product page stayed blank.


Quote:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/mysite/public_html/films/include/func.php on line 2221

Warning: fsockopen(): unable to connect to www.mysite.com::80 in /home/mysite/public_html/films/include/func.php on line 2221


isi 07-11-2005 02:21 PM

Did anyone get this working in 4.x? Seems like a great time saving mod.

----
ISI
X-Cart 4.0.13


All times are GMT -8. The time now is 07:53 PM.

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