Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Assigning manufacturers to multiple items

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 06-22-2006, 04:11 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default 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
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:11 AM.

   

 
X-Cart forums © 2001-2020