💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 通过商品ID的查询商品规格&属性值 **位置:** Common\Common\function.php jig 2018-06-26 **参数:** * @param int $goods_id spu_id/sku_id/item_id * @param int $attr_id 属性ID * @param int $goods_type 属性类型 1:唯一码 2:SPU 3:SKU **调用:** > PHP 调用: print_attr ($goods_id, 1, 3) > View 模版调用: {$vo['goods_id'], 1, 3, |print_attr} 通过SKU获取颜色值 **完整代码:** ~~~ /** * 通过商品ID的查询商品规格&属性值 * jig 2018-06-26 * * @param int $goods_id spu_id/sku_id/item_id * @param int $attr_id 属性ID * @param int $goods_type 属性类型 1:唯一码 2:SPU 3:SKU * * @return string */ function print_attr ($goods_id, $attr_id, $goods_type) { $where = array ( 'goods_id' => $goods_id, 'attr_id' => $attr_id, 'goods_type' => $goods_type, 'is_delete' => 0 ); $result = M('goods_attr_relation')->where($where)->find(); return $result['attr_value']; } ~~~