新添商品 此商品不存在规格,请为其添加规格 的解决方法
post by:sunshine 2016-4-17 20:56
admin/includes/lib_goods.php
里面的
check_goods_specifications_exist 函数替换以下内容就可以了
/**
* 检查单个商品是否存在规格
*
* @param int $goods_id 商品id
* @return bool true,存在;false,不存在
*/
function check_goods_specifications_exist($goods_id)
{
$goods_id = intval($goods_id);
$sql = "SELECT a.attr_id
FROM " .$GLOBALS['ecs']->table('attribute'). " AS a, " .$GLOBALS['ecs']->table('goods'). " AS g
WHERE a.cat_id = g.goods_type
AND g.goods_id = '$goods_id'
AND a.attr_type='1'";
$a = $GLOBALS['db']->getAll($sql);
foreach ($a as $val)
{
$att[]=$val['attr_id'];
}
$sql= "SELECT count(goods_attr_id ) FROM
".$GLOBALS['ecs']->table('goods_attr')."as a WHERE a.goods_id
='$goods_id' AND a.attr_id ".db_create_in($att);
$count=$GLOBALS['db']->getOne($sql);
if ($count > 0)
{
return true; //存在
}
else
{
return false; //不存在
}
}
如果是 使用了规格,那么会正常跳转货品列表中,如果未使用规格,则跳转到添加新商品页面