批量删除Zen Cart 无图片商品

<?php    
    /**
     * 
     *  @ 批量删除Zen Cart 无图片商品  
     *  @ 使用方法: 将本文件上传到网站根目录下运行 http://你的域名/zcdelpro.php  
     *  @ $status = 'delete';  //删除没有图片的产品
     *  @ $status = 'hide';    //下架没有图片的产品
     *  @ $status = 'default'; //列出没有图片的产品
* @ 作者QQ: 631992791 *
*/ $status = 'default'; $no_img_id = array(); require("includes/application_top.php"); $pro_list = $db->Execute("select products_id, products_image from ".TABLE_PRODUCTS); while (!$pro_list->EOF){ if(file_exists(DIR_WS_IMAGES.$pro_list->fields['products_image']) && filesize(DIR_WS_IMAGES.$pro_list->fields['products_image']) > 0 && preg_match('/.*\.(jpg|bmp|gif|png)$/Uis', $pro_list->fields['products_image'])) { //echo 'ID为 '.$products_list->fields['products_id'].' 的产品图片正常<br />'; }else{ if($status == 'delete'){ $db->Execute('delete from '.TABLE_PRODUCTS. ' where products_id='.$pro_list->fields['products_id']); $db->Execute('delete from '.TABLE_PRODUCTS_ATTRIBUTES. ' where products_id='.$pro_list->fields['products_id']); $db->Execute('delete from '.TABLE_PRODUCTS_DESCRIPTION. ' where products_id='.$pro_list->fields['products_id']); $db->Execute('delete from '.TABLE_PRODUCTS_TO_CATEGORIES. ' where products_id='.$pro_list->fields['products_id']); echo 'ID为 '.$pro_list->fields['products_id'].' 产品已删除<br />'; }elseif($status == 'hide'){ $db->Execute('update '.TABLE_PRODUCTS. ' set products_status = 0 where products_id='.$pro_list->fields['products_id']); echo 'ID为 '.$pro_list->fields['products_id'].' 产品已下架<br />'; }else{ $no_img_id[] = $pro_list->fields['products_id']; echo 'ID为 '.$pro_list->fields['products_id'].' 产品无图片<br />'; } } $pro_list->MoveNext(); } if($status != 'delete' && $status != 'hide'){ echo '<span style="color:#090;">删除没有图片的产品请将第10行改为 $status = "delete";<br />下架没有图片的产品请将第10行改为 $status = "hide";<br /></span>'; if(count($no_img_id)>0){ echo '没有图片的产品列表:<br />'; foreach($no_img_id as $id){ echo '<a href="http://'.$_SERVER['HTTP_HOST'].DIR_WS_CATALOG.'index.php?main_page=product_info&products_id='.$id.'" target="_blank">查看ID为'.$id.'的产品</a><br />'; } } } ?>

 

posted @ 2014-08-18 17:18  小鱼阁工作室  阅读(288)  评论(0编辑  收藏  举报
Copyright © 小鱼阁工作室 版权所有 -zencart外贸建站,织梦企业建站,ecshop商城,二次开发,产品采集,模板修改!