商品导出中排除掉已下架的商品,应该怎么做啊,谢谢

2016-07-07 15:17 来源:www.chinab4c.com 作者:ecshop专家

在这个函数中,我已添加了一个g.is_on_sale =的条件,但如不选择关键字,直接导出所有的,还是会把已下架的导出来,应该应该怎么实现啊,谢谢
function get_export_where_sql($filter)
{
$where = '';
if (!empty($filter['goods_ids']))
{
$goods_ids = explode(',', $filter['goods_ids']);
if (is_array($goods_ids) && !empty($goods_ids))
{
$goods_ids = array_unique($goods_ids);
$goods_ids = "'" . implode("','", $goods_ids) . "'";
}
else
{
$goods_ids = "'0'";
}
$where = " WHERE g.is_on_sale =1 and g.is_delete = 0 AND g.goods_id IN (" . $goods_ids . ") ";
}
else
{
$_filter = new StdClass();
$_filter->cat_id = $filter['cat_id'];
$_filter->brand_id = $filter['brand_id'];
$_filter->keyword = $filter['keyword'];
$where = get_where_sql($_filter);
}
return $where;
}
这个函数我已加了条件,但如不点搜索,也就是下面部分还是会导出所有的商品,请问怎么改啊,谢谢


回答:
问题已解决,请看红字
function get_export_where_sql($filter)
{
$where = '';
if (!empty($filter['goods_ids']))
{
$goods_ids = explode(',', $filter['goods_ids']);
if (is_array($goods_ids) && !empty($goods_ids))
{
$goods_ids = array_unique($goods_ids);
$goods_ids = "'" . implode("','", $goods_ids) . "'";
}
else
{
$goods_ids = "'0'";
}
$where = " WHERE g.is_on_sale =1 and g.is_delete = 0 AND g.goods_id IN (" . $goods_ids . ") ";//这里注意g.is_on_sale=1
}
else
{
$_filter = new StdClass();
$_filter->cat_id = $filter['cat_id'];
$_filter->brand_id = $filter['brand_id'];
$_filter->keyword = $filter['keyword'];
$where = get_where_sql($_filter);
$where =$where.' and g.is_on_sale =1 and g.is_delete = 0';//添加这句

}
return $where;
}

这个很好啊。

想知道下架商品的数据库字段是什么,如何设置?有木有能回答地