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

Adding images using ftp (bulk)

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-26-2006, 03:35 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

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

Default Adding images using ftp (bulk)

I have a php file that pulls all of the products without images from the db.

It then creates a table with these products, and looks for images with the sku as the image name in either jpg or gif. Under each image is a checkbox, that once clicked will assign that image to the product

common_templates.tpl: add the following:

Code:
{elseif $main eq "prodwithoutimg"} {include file="provider/prodwithoutimg.tpl"}

replace www.yourdomain.com with your domain name and
http://www.yourdomain.com/skin1/products/jpgs/ with the path to your images folder
then upload the following as prodwithoutimg.php to your provider folder:

Code:
<?php # # $Id: prodwithoutimg.php,v 0.1 2005/22/11 12:25:55 AH # require "./auth.php"; require $xcart_dir."/include/security.php"; #$addarray[] = $HTTP_POST_VARS['addarray']; if (isset($_POST["format"])) { $format = $_POST["format"]; } if (is_array($disablearray)) { foreach ($disablearray as $prod) { db_query("UPDATE xcart_products SET forsale='N' WHERE productid='$prod'"); } } if (is_array($lowercase)) { foreach ($lowercase as $key => $value) { $prodid = $key; $fileurl = $lowercase[$key][fileurl]; db_query("UPDATE xcart_products SET productcode=LOWER(productcode) WHERE productid='$prodid'"); } } if (is_array($addjpgs)) { foreach ($addjpgs as $key => $value) { $prodid = $key; $fileurl = $addjpgs[$key][fileurl]; db_query("INSERT INTO xcart_thumbnails (productid,image_path,image_type) VALUES ('$prodid','$fileurl','image/jpeg')"); } } if (is_array($addgifs)) { foreach ($addgifs as $key => $value) { $prodid = $key; $fileurl = $addgifs[$key][fileurl]; db_query("INSERT INTO xcart_thumbnails (productid,image_path,image_type) VALUES ('$prodid','$fileurl','image/gif')"); } } $productlisting = func_query("SELECT xcart_products.productid, xcart_products.productcode, xcart_products.product, xcart_products.avail FROM xcart_products LEFT OUTER JOIN xcart_thumbnails ON xcart_products.productid = xcart_thumbnails.productid WHERE xcart_thumbnails.productid IS NULL AND xcart_products.forsale='Y' ORDER BY xcart_products.productcode ASC"); $smarty->assign("productlisting",$productlisting); $smarty->assign("main","prodwithoutimg"); $smarty->assign("addarray",$addarray); $smarty->assign("addjpgs",$addjpgs); $smarty->assign("addgifs",$addgifs); $smarty->assign("format",$format); @include $xcart_dir."/modules/gold_display.php"; $smarty->display("provider/prodwithoutimg.tpl"); ?>

upload the following as prodwithoutimg.tpl to your skin1/provider folder:
Code:
{capture name=dialog} <form action="prodwithoutimg.php" method="post"> <INPUT TYPE=RADIO NAME="format" VALUE="list">List View <INPUT TYPE=RADIO NAME="format" VALUE="image">Image View <INPUT TYPE=submit value="Change"> {if $format eq "list"} <table border=1> {section name=productlisting loop=$productlisting} {assign var="prodid" value=$productlisting[productlisting].productid} {assign var="total" value=$smarty.section.productlisting.total} <TR> <td> {$productlisting[productlisting].product} </td><td> Code:{ $productlisting[productlisting].productcode } </td><td> ID: {$productlisting[productlisting].productid} </td><td> Disable: <INPUT TYPE=CHECKBOX value="{$productlisting[productlisting].productid}" NAME="disablearray[]"> <INPUT TYPE=submit value="PROCESS ALL"> </TD> </tr> {/section} </table> {else} <table border=1> {section name=productlisting loop=$productlisting} {assign var="prodid" value=$productlisting[productlisting].productid} {assign var="total" value=$smarty.section.productlisting.total} { if $smarty.section.productlisting.index is div by 3} <TR> {/if} <TD> <table><tr><td> [img]http://www.yourdomain.com/skin1/products/jpgs/{ $productlisting[productlisting].productcode}.jpg[/img] thumb jpeg <INPUT TYPE="CHECKBOX" NAME="addjpgs[{$prodid}][fileurl]" value="http://www.yourdomain.com/skin1/products/jpgs/{ $productlisting[productlisting].productcode }.jpg">JPG </td> <td> [img]http://www.yourdomain.com/skin1/products/jpgs/{ $productlisting[productlisting].productcode}.gif[/img] thumb gif <INPUT TYPE="CHECKBOX" NAME="addgifs[{$prodid}][fileurl]" value="http://www.yourdomain.com/skin1/products/jpgs/{ $productlisting[productlisting].productcode }.gif"> gif </td></tr></table> {$productlisting[productlisting].product} Code:{ $productlisting[productlisting].productcode } ID: {$productlisting[productlisting].productid} Qty: {$productlisting[productlisting].avail} lowercase: <INPUT TYPE="CHECKBOX" NAME="lowercase[{$prodid}][fileurl]" CHECKED> Disable: <INPUT TYPE=CHECKBOX value="{$productlisting[productlisting].productid}" NAME="disablearray[]"> <INPUT TYPE=submit value="PROCESS ALL"> </TD> { if $smarty.section.productlisting.index_next is div by 3} </TR> {/if} {/section} </table> {/if} </form> {/capture} {include file="dialog.tpl" title="Products Without Images ($total)" content=$smarty.capture.dialog extra="width=100%"}

add a link to a menu in your admin area to provider/prodwithoutimg.php

ticking the checkbox underneath the image will assign that image to that product.

You can also disable products using the disable checkbox

Be warned this can take a long time if you have a lot of products without images as it is looking for 2 images for each product that may not be there.

Use at your own risk etc etc

I find it very useful and I hope it helps anyone, I am using it on v 4.0.18
__________________
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
  #2  
Old 05-26-2006, 05:15 AM
 
oracle9i oracle9i is offline
 

Member
  
Join Date: Feb 2006
Posts: 29
 

Default

havnt tried it but the idea is fantastic. thanks mate
__________________
X-CART 4.0.4 (about to upgrade to 4.0.17)
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 10:24 AM.

   

 
X-Cart forums © 2001-2020