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)
-   -   Assigning manufacturers to multiple items (https://forum.x-cart.com/showthread.php?t=22691)

amy2203 06-22-2006 04:11 AM

Assigning manufacturers to multiple items
 
I recently upgraded to 4.0.18 from 3.5.10, and one of the new things is the whole manufacturer thing, but none of my products had this data so I'm having to add it for all of them (loads and loads.....)

to make it quicker i wrote this php file. It lists all of the products without a manufacturer in the xcart_products table, and creates a drop sown box for each listing all of the manufacturers.

Notes:

I have it set to only show 20 at once, saves me scrolling. Cahnge loop=20 to whatever number you like, or {$productlisting} to list them all.

Add the following code to common_templates.tpl

Code:

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


Copy the following and save as ag_manufacturers.php and place in your /provider folder
Code:

<?php


#
# $Id: ag_manufacturers.php,v 0.1 2006/06/22 AG
#


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

if (is_array($ag_manufacturer)) {
$smarty->assign("ag_manufacturer",$ag_manufacturer);

foreach ($ag_manufacturer as $prod => $manid){
        $query = "UPDATE xcart_products SET manufacturerid='$manid' WHERE productid='$prod'";
        db_query($query);
        }
}


$manufacturers = func_query("SELECT * FROM xcart_manufacturers");

$productlisting = func_query("SELECT xcart_products.productid, xcart_products.product, xcart_products.productcode FROM xcart_products WHERE xcart_products.manufacturerid='' AND xcart_products.forsale='Y' ORDER BY xcart_products.productid DESC");


$smarty->assign("manufacturers",$manufacturers);
$smarty->assign("productlisting",$productlisting);
$smarty->assign("main","ag_man");


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


save the following as ag_manufacturers.tpl and place in your skin1/provider folder
Code:


{capture name=dialog}

<form action="ag_manufacturers.php" method="post">

<table border=0>
<TR>
<TD height="10">Product ID</TD>
<TD height="10">Product SKU</TD>
<TD height="10">Product Name</TD>
<TD height="10">Manufacturer</TD>

</TR>

{section name=productlisting loop=20}
{assign var="total" value=$smarty.section.productlisting.total}
<TR>
<TD height="10">{$productlisting[productlisting].productid}</TD>
<TD height="10">{$productlisting[productlisting].productcode}</TD>
<TD height="10">{$productlisting[productlisting].product}</TD>

<TD height="10">
<select name="ag_manufacturer[{$productlisting[productlisting].productid}]">
<option value=""></option>

{section name=manufacturerlist loop=$manufacturers}
<option value="{$manufacturers[manufacturerlist].manufacturerid}">{$manufacturers[manufacturerlist].manufacturer}</option>
{/section}
</select>
</TD>
</TR>

{/section}
<TR>
<TD height="10"></TD>
<TD height="10"></TD>
<TD height="10"></TD>
<TD height="10"></TD>
<TD height="10"><INPUT TYPE=submit name="Submit" value="Submit"></TD>
</TR>
</table>
</form>
{/capture}
{include file="dialog.tpl" title="Manufacturers To Do" content=$smarty.capture.dialog extra="width=100%"}


I take no responsability for this destroying everything. It seems to work on my set up, but use at your own risk etc etc...

hth


All times are GMT -8. The time now is 09:47 AM.

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