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