123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace Product\Lib;
- use Dever;
- class Sku
- {
- # 获取当前的sku
- public function get_api()
- {
- $id = Dever::input('id');
- $result = array();
- if ($id) {
- $result = Dever::db('product/info_sku')->getAll(array('info_id' => $id));
- }
- return $result;
- }
- # 获取某个商品的sku商品列表
- public function getList($info, &$data)
- {
- if ($info['spec_type'] == 2) {
- $where['info_id'] = $info['id'];
- $sku = Dever::db('product/info_sku')->select($where);
- if ($sku) {
- foreach ($sku as $k => $v) {
- $copy = $info;
- $key = str_replace('-', ',', $v['key']);
- $spec = Dever::db('product/info_spec_value')->getGroupData(array('ids' => $key));
- if ($spec) {
- $copy['name'] .= '-' . $spec['name'];
- $copy['id'] .= '-' . $v['key'];
- if (isset($copy['value'])) {
- $copy['value'] = $copy['id'];
- }
- }
-
- $data[] = $copy;
- }
- }
- } else {
- $data[] = $info;
- }
-
- return $data;
- }
- # 获取基本信息列表
- public function getData($info_id, $sku_id = false)
- {
- $where['info_id'] = $info_id;
- if ($sku_id) {
- $where['id'] = $sku_id;
- }
- $sku = Dever::db('product/info_sku')->select($where);
- return $sku;
- if ($sku) {
- foreach ($sku as $k => $v) {
- $key = str_replace('-', ',', $v['key']);
- $spec = Dever::db('product/info_spec_value')->getData(array('ids' => $key));
- if ($spec) {
- $copy['name'] .= '-' . $spec['name'];
- $copy['id'] .= '-' . $v['key'];
- if (isset($copy['value'])) {
- $copy['value'] = $copy['id'];
- }
- }
-
- $data[] = $copy;
- }
- }
- return $data;
- }
- }
|