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)
-   -   Import product options (https://forum.x-cart.com/showthread.php?t=4350)

finestshops 09-14-2003 08:18 AM

Import product options
 
Here is my mod for batch upload of product options:

here is format of file for options import:

productcode, opttext, options

Code:

1044, Color, Black\r\nRed\r\nRoyal Blue
1044, Size, Regular\r\nXL
1068, Color, Black\r\nPeriwinkle\r\nWhite
1069, Color, Natural\r\nPurple\r\nTurquoise
1076, Color, Gold\r\nSilver
1076, Size, Regular\r\nXL
1139, Color, Black\r\nRed\r\nWhite
1139, Size, S\r\nM\r\nL
116, Color, Black\r\nWhite


create new file "xcart/provider/options_update.php"

Code:

<?
/*****************************************************************************\
+-----------------------------------------------------------------------------+
| X-Cart                                                                      |
| Copyright (c) 2001-2003 Ruslan R. Fazliev <rrf@rrf.ru>                      |
| All rights reserved.                                                        |
+-----------------------------------------------------------------------------+
| PLEASE READ  THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "COPYRIGHT" |
| FILE PROVIDED WITH THIS DISTRIBUTION. THE AGREEMENT TEXT IS ALSO AVAILABLE  |
| AT THE FOLLOWING URL: http://www.x-cart.com/license.php                    |
|                                                                            |
| THIS  AGREEMENT  EXPRESSES  THE  TERMS  AND CONDITIONS ON WHICH YOU MAY USE |
| THIS SOFTWARE  PROGRAM  AND  ASSOCIATED  DOCUMENTATION  THAT  RUSLAN  R. |
| FAZLIEV (hereinafter  referred to as "THE AUTHOR") IS FURNISHING  OR MAKING |
| AVAILABLE TO YOU WITH  THIS  AGREEMENT  (COLLECTIVELY,  THE  "SOFTWARE").  |
| PLEASE  REVIEW  THE  TERMS  AND  CONDITIONS  OF  THIS  LICENSE AGREEMENT |
| CAREFULLY  BEFORE  INSTALLING  OR  USING  THE  SOFTWARE.  BY INSTALLING, |
| COPYING  OR  OTHERWISE  USING  THE  SOFTWARE,  YOU  AND  YOUR  COMPANY |
| (COLLECTIVELY,  "YOU")  ARE  ACCEPTING  AND AGREEING  TO  THE TERMS OF THIS |
| LICENSE  AGREEMENT.  IF  YOU    ARE  NOT  WILLING  TO  BE  BOUND BY THIS |
| AGREEMENT, DO  NOT INSTALL OR USE THE SOFTWARE.  VARIOUS  COPYRIGHTS  AND |
| OTHER  INTELLECTUAL  PROPERTY  RIGHTS    PROTECT  THE  SOFTWARE.  THIS |
| AGREEMENT IS A LICENSE AGREEMENT THAT GIVES  YOU  LIMITED  RIGHTS  TO  USE |
| THE  SOFTWARE  AND  NOT  AN  AGREEMENT  FOR SALE OR FOR  TRANSFER OF TITLE.|
| THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT.      |
|                                                                            |
| The Initial Developer of the Original Code is Ruslan R. Fazliev            |
| Portions created by Ruslan R. Fazliev are Copyright (C) 2001-2003          |
| Ruslan R. Fazliev. All Rights Reserved.                                    |
+-----------------------------------------------------------------------------+
\*****************************************************************************/

#
# $Id: options_update.php,v 1 2003/09/10 ant Exp $
#

# $columns[0] - productcode
# $columns[1] - opttext
# $columns[2] - options

@set_time_limit(1800);

require "../smarty.php";
require "../config.php";
require "./auth.php";
require "../include/security.php";

if ($REQUEST_METHOD=="POST") {

        $provider_condition=($single_mode?"":" AND $sql_tbl[products].provider='$login'");
       
        if($fp = @fopen($userfile,"r")) {
                while ($columns = fgetcsv ($fp, 65536, $delimiter)) {
                        if ($columns[0]) {
                                if ($what == "p") {
                                        $pid = func_query_first ("SELECT * FROM $sql_tbl[products] WHERE productcode='$columns[0]' $provider_condition");

                                        $f = "SELECT count(*) FROM $sql_tbl[product_options] WHERE productid='$pid[productid]' AND optclass='$columns[1]'";
                                        echo $f."
";
                                        $tmp = array_pop(func_query_first($f));
                                        # $tmp = db_query ($f);
                                        # echo $tmp."
";
                               
                                        if ($tmp != 0)
                                        {
                                        $f = "UPDATE $sql_tbl[product_options] SET optclass='$columns[1]', opttext='$columns[1]', options='$columns[2]' WHERE productid='$pid[productid]'";
                                        echo $f."
";
                                        db_query ($f);
                                        }
                                        else
                                        {
                                        $f = "INSERT $sql_tbl[product_options] VALUES ('','$pid[productid]','$columns[1]','$columns[1]','$columns[2]','0')";
                                        echo $f."
";
                                        db_query ($f);
                                        }
                                }
                        }
                }
                $smarty->assign("main", "options_updated");
        } else {
                $smarty->assign("main", "error_inv_update");
        }
} else {
        $smarty->assign ("main", "options_update");
}

require "../include/categories.php";

@include "../modules/gold_display.php";
$smarty->display("provider/home.tpl");
?>




create new template "\skin1\provider\main\options_update.tpl

Code:

{* $Id: options_update.tpl,v 1.0 2003/09/10 ant Exp $ *}
{include file="location.tpl" last_location="Price update"}
{capture name=dialog}


<h3><font color=red>Script is in testing! Please back up database!</font></h3>


<FORM method=POST action="options_update.php" enctype="multipart/form-data">
<TABLE border=0 cellpadding=0 cellspacing=4 width="100%">

<TR>
<TD>Update</TD>
<TD><SELECT name=what>
 <OPTION value="p" selected>Options</OPTION>
</SELECT></TD>
</TR>
<TR>
<TD>CSV delimiter</TD>
<TD>{include file="provider/main/ie_delimiter.tpl"}</TD>
</TR>
<TR>
<TD>CSV file</TD>
<TD><INPUT type=file name=userfile></TD>
</TR>
<TR>
<TD colspan=2><INPUT type=submit value="Update">
</TABLE>
</FORM>
{/capture}
{include file="dialog.tpl" content=$smarty.capture.dialog title="Options Update" extra="width=100%"}


in template "\skin1\single\home.tpl"

after

Code:

{elseif $main eq "inv_update"}
{include file="provider/main/inv_update.tpl"}


add

Code:

{elseif $main eq "options_update"}
{include file="provider/main/options_update.tpl"}


in "\skin1\provider\menu.tpl"
after


add


The script will check if option is exist for productcode and update it
if yes or insert it if no.

I have similar script for price update by membership.

Hope this will help somebody,

ATKOgirl 09-14-2003 02:19 PM

Hi Anton,

Looks good! We'll give it a try on our next upload.

Thanks!

ATKOgirl

dealsondeals 09-27-2003 07:42 PM

:D Thanks!

I have implemented it and will test it over the next week.

Regards,

Glen

funkydunk 10-08-2003 12:00 AM

This functionality will be standard in version 3.5.x

Great mod though - looks like it would work well.:)

dealsondeals 10-08-2003 06:02 AM

:?: FunkyDunk,

Any preliminary estimates on a release date for version 3.5x?

Regards,

Glen

finestshops 10-08-2003 06:15 AM

one of x-men told me it'll reliased be in a month (~)

funkydunk 10-08-2003 06:17 AM

what do you call a deer that cant see? :wink:

dont think it will be long though - probably within the month is my guess. :D

dealsondeals 10-08-2003 06:21 AM

8O In a month? Wow!

Are we looking at significant changes? Or just some additonal functionality like this?

Regards,

Glen

funkydunk 10-08-2003 06:40 AM

some good changes, but not change for the sake of it. :)

lildawg 11-04-2003 11:40 AM

Does this allow for when importing lets say a 1XL to still be able to add more money if that size is choosen? Example would be in x-cart adding a option I would put 1XL=+5 to add $5.00 to the base price if that is choosen. Has anyone done this yet and know?


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

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