Sku.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <?php
  2. namespace Goods\Lib;
  3. use Dever;
  4. class Sku
  5. {
  6. # 设置sku特殊字段
  7. private $col = array
  8. (
  9. 's_price' => '市场价',
  10. 'f_price' => '采购价',
  11. 'price' => '销售价',
  12. 'min' => '起购数',
  13. );
  14. # 主要价格字段
  15. private $main = 'price';
  16. public function __construct()
  17. {
  18. # 设置权限
  19. Dever::load('manage/auth.init');
  20. }
  21. public function config()
  22. {
  23. $data['action'] = Dever::url('goods/lib/sku.update');
  24. $data['goods_id'] = Dever::input('goods_id');
  25. $data['other'] = Dever::input('other');
  26. $data['other_id'] = Dever::input('other_id');
  27. if ($data['other']) {
  28. $data['other_col'] = $data['other'] . '_id';
  29. }
  30. $data['attr'] = Dever::input('attr');
  31. $data['key'] = Dever::input('key');
  32. $data['single_attr'] = Dever::input('single_attr');
  33. $data['single_key'] = Dever::input('single_key');
  34. $data['input_attr'] = Dever::input('input_attr');
  35. $data['input_key'] = Dever::input('input_key');
  36. $data['hook'] = Dever::input('hook');
  37. $data['set'] = $this->getSet($data['other']);
  38. return $data;
  39. }
  40. private function getSet($other)
  41. {
  42. if ($other) {
  43. if (Dever::project($other)) {
  44. $set = Dever::load($other . '/lib/sku')->set;
  45. if (!isset($set['price_type'])) {
  46. $set['price_type'] = false;
  47. }
  48. } else {
  49. Dever::alert($other . '不存在');
  50. }
  51. } else {
  52. $set = array('col' => $this->col, 'price_type' => false);
  53. }
  54. return $set;
  55. }
  56. public function show()
  57. {
  58. $config = Dever::load('goods/lib/sku')->config();
  59. return $this->table($config['goods_id'], $config['other'], $config['other_id'], $config['set'], true);
  60. }
  61. public function update_api()
  62. {
  63. $config = Dever::load('goods/lib/sku')->config();
  64. $where = array();
  65. if ($config['other']) {
  66. $where[$config['other_col']] = $config['other_id'];
  67. $where['goods_id'] = $config['goods_id'];
  68. $key = 'sku_id';
  69. $table = $config['other'] . '/goods';
  70. } else {
  71. $where['info_id'] = $config['goods_id'];
  72. $key = 'key';
  73. $table = 'goods/info';
  74. }
  75. $sku_table = $table . '_sku';
  76. $w['option_info_id'] = $config['goods_id'];
  77. $w['set_state'] = 2;
  78. Dever::db('goods/info_sku')->updates($w);
  79. if ($config['key'] == -1) {
  80. if ($config['other']) {
  81. $info = Dever::db($table)->one($where);
  82. } else {
  83. $info = Dever::db($table)->one($config['goods_id']);
  84. }
  85. $update = $where;
  86. foreach ($config['set']['col'] as $k => $v) {
  87. $update[$k] = Dever::input($k);
  88. }
  89. if ($info && $update) {
  90. $update['where_id'] = $info['id'];
  91. Dever::db($table)->update($update);
  92. unset($update['where_id']);
  93. }
  94. $where[$key] = -1;
  95. $info = Dever::db($sku_table)->one($where);
  96. $update[$key] = $where[$key];
  97. Dever::config('base')->hook = false;
  98. if (!$info) {
  99. $state = Dever::db($sku_table)->insert($update);
  100. } else {
  101. $update['where_id'] = $info['id'];
  102. $update['state'] = 1;
  103. $state = Dever::db($sku_table)->update($update);
  104. }
  105. } elseif ($config['key']) {
  106. if (!is_array($config['key'])) {
  107. $config['key'] = explode(',', $config['key']);
  108. }
  109. $min = array();
  110. $cur_sku = false;
  111. $sku_id = false;
  112. foreach ($config['key'] as $k => $v) {
  113. $type = 1;
  114. if (strstr($v, '||')) {
  115. $temp = explode('||', $v);
  116. $v = $temp[0];
  117. $type = $temp[1];
  118. }
  119. if (isset($config['attr'][$k])) {
  120. $data = $where;
  121. if ($config['other']) {
  122. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  123. if (!$sku) {
  124. continue;
  125. }
  126. $data[$key] = $sku['id'];
  127. $info = Dever::db($sku_table)->one($data);
  128. } else {
  129. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  130. $data['attr'] = $config['attr'][$k];
  131. $data[$key] = $v;
  132. }
  133. $data['type'] = $type;
  134. foreach ($config['set']['col'] as $k1 => $v1) {
  135. $value = Dever::input($k1);
  136. $cur_sku = false;
  137. if (isset($value[$k])) {
  138. $data[$k1] = $value[$k];
  139. if ($k1 == $this->main) {
  140. if (!isset($min[$k1])) {
  141. $min = $data;
  142. $cur_sku = true;
  143. } elseif ($min[$k1] > $data[$k1]) {
  144. $min = $data;
  145. $cur_sku = true;
  146. }
  147. }
  148. }
  149. }
  150. Dever::config('base')->hook = false;
  151. if (!$info) {
  152. $temp = Dever::db($sku_table)->insert($data);
  153. if ($cur_sku) {
  154. $sku_id = $temp;
  155. }
  156. } else {
  157. $data['where_id'] = $info['id'];
  158. if ($cur_sku) {
  159. $sku_id = $data['where_id'];
  160. }
  161. $data['state'] = 1;
  162. Dever::db($sku_table)->update($data);
  163. }
  164. }
  165. }
  166. if (!$config['other'] && $min) {
  167. $update = array();
  168. if ($sku_id) {
  169. $update['sku_id'] = $sku_id;
  170. }
  171. foreach ($config['set']['col'] as $k => $v) {
  172. if (isset($min[$k])) {
  173. $update[$k] = $min[$k];
  174. }
  175. }
  176. $update['where_id'] = $config['goods_id'];
  177. Dever::db($table)->update($update);
  178. }
  179. }
  180. if ($config['single_key']) {
  181. if (!is_array($config['single_key'])) {
  182. $config['single_key'] = explode(',', $config['single_key']);
  183. }
  184. foreach ($config['single_key'] as $k => $v) {
  185. $type = 2;
  186. if (strstr($v, '||')) {
  187. $temp = explode('||', $v);
  188. $v = $temp[0];
  189. $type = $temp[1];
  190. }
  191. if (isset($config['single_attr'][$k])) {
  192. $data = $where;
  193. if ($config['other']) {
  194. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  195. if (!$sku) {
  196. continue;
  197. }
  198. $data[$key] = $sku['id'];
  199. $info = Dever::db($sku_table)->one($data);
  200. } else {
  201. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  202. $data['attr'] = $config['single_attr'][$k];
  203. $data[$key] = $v;
  204. }
  205. $data['type'] = $type;
  206. foreach ($config['set']['col'] as $k1 => $v1) {
  207. $value = Dever::input('single_' . $k1);
  208. if (isset($value[$k])) {
  209. $data[$k1] = $value[$k];
  210. }
  211. }
  212. Dever::config('base')->hook = false;
  213. if (!$info) {
  214. $temp = Dever::db($sku_table)->insert($data);
  215. } else {
  216. $data['where_id'] = $info['id'];
  217. $data['state'] = 1;
  218. Dever::db($sku_table)->update($data);
  219. }
  220. }
  221. }
  222. }
  223. if ($config['input_key']) {
  224. if (!is_array($config['input_key'])) {
  225. $config['input_key'] = explode(',', $config['input_key']);
  226. }
  227. foreach ($config['input_key'] as $k => $v) {
  228. $type = 3;
  229. if (strstr($v, '||')) {
  230. $temp = explode('||', $v);
  231. $v = $temp[0];
  232. $type = $temp[1];
  233. }
  234. if (isset($config['input_attr'][$k])) {
  235. $data = $where;
  236. if ($config['other']) {
  237. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  238. if (!$sku) {
  239. continue;
  240. }
  241. $data[$key] = $sku['id'];
  242. $info = Dever::db($sku_table)->one($data);
  243. } else {
  244. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  245. $data['attr'] = $config['input_attr'][$k];
  246. $data[$key] = $v;
  247. }
  248. $data['type'] = $type;
  249. foreach ($config['set']['col'] as $k1 => $v1) {
  250. $value = Dever::input('input_' . $k1);
  251. if (isset($value[$k])) {
  252. $data[$k1] = $value[$k];
  253. }
  254. }
  255. Dever::config('base')->hook = false;
  256. if (!$info) {
  257. $temp = Dever::db($sku_table)->insert($data);
  258. } else {
  259. $data['where_id'] = $info['id'];
  260. $data['state'] = 1;
  261. Dever::db($sku_table)->update($data);
  262. }
  263. }
  264. }
  265. }
  266. Dever::config('base')->hook = true;
  267. Dever::out('yes');
  268. }
  269. public function table($goods, $other = false, $other_id = false, $set = false, $update = true, $parent_goods = false)
  270. {
  271. if (!$set) {
  272. $set = $this->getSet($other);
  273. }
  274. $info = is_array($goods) ? $goods : Dever::db('goods/info')->one($goods);
  275. $info = Info::init(-1)->info($info, 'view_reorder');
  276. if ($info && $other && isset($set['price_type']) && $set['price_type']) {
  277. $price_type = explode(',', $set['price_type']);
  278. if (in_array($info['price_type'], $price_type)) {
  279. if ($update) {
  280. return '组合商品无法设置库存';
  281. }
  282. if ($info['goods'] && is_array($info['goods'])) {
  283. $html = '';
  284. foreach ($info['goods'] as $k => $v) {
  285. $html .= $this->table($v['id'], $other, $other_id, $set, $update, $v) . '<br />';
  286. }
  287. $html .= '*组合商品的库存为以上商品中的最低库存为准';
  288. return $html;
  289. } else {
  290. return '';
  291. }
  292. }
  293. }
  294. $input = '';
  295. $sku_value = array();
  296. if ($other) {
  297. $other_col = $other . '_id';
  298. $sku_value = Dever::db($other . '/goods_sku')->getData(array('goods_id' => $info['id'], $other_col => $other_id, 'state_1' => 1));
  299. $input = '<input type="hidden" name="goods_id" value="'.$info['id'].'"/><input type="hidden" name="'.$other_col.'" value="'.$other_id.'"/>';
  300. }
  301. $sku = Dever::db('goods/info_sku')->getDataByKeys(array('info_id' => $info['id']));
  302. $group_attr = $single_attr = $input_attr = array();
  303. $head = $single_head = $input_head = '<thead><tr>';
  304. $html = '请先选择属性';
  305. if ($parent_goods) {
  306. $head .= '<th>商品名称</th>';
  307. $single_head .= '<th>商品名称</th>';
  308. $input_head .= '<th>商品名称</th>';
  309. }
  310. if (isset($info['group_attr']) && $info['group_attr']) {
  311. foreach ($info['group_attr'] as $k => $v) {
  312. if (isset($info['attr'][$v]['option'])) {
  313. $group_attr[$k] = $info['attr'][$v]['option'];
  314. $head .= '<th>'.$info['attr'][$v]['name'].'</th>';
  315. }
  316. }
  317. }
  318. if (isset($info['single_attr']) && $info['single_attr']) {
  319. $single_head .= '<th>属性名称</th>';
  320. foreach ($info['single_attr'] as $k => $v) {
  321. if (isset($info['attr'][$v]['option'])) {
  322. $single_attr = array_merge($single_attr, $info['attr'][$v]['option']);
  323. }
  324. }
  325. }
  326. if (isset($info['input_attr']) && $info['input_attr']) {
  327. $input_head .= '<th>属性名称</th>';
  328. $input_head .= '<th>起算</th>';
  329. foreach ($info['input_attr'] as $k => $v) {
  330. if (isset($info['attr'][$v]['option'])) {
  331. $input_attr[$k] = $info['attr'][$v];
  332. }
  333. }
  334. }
  335. $col_num = 0;
  336. foreach ($set['col'] as $k => $v) {
  337. if (!$update && strstr($v, '^')) {
  338. continue;
  339. }
  340. $col_num++;
  341. if (strstr($v, '^')) {
  342. $v = str_replace('^', '', $v);
  343. }
  344. if (strstr($v, '|')) {
  345. $v = str_replace('|', '', $v);
  346. }
  347. $head .= '<th>'.$v.'</th>';
  348. $single_head .= '<th>'.$v.'</th>';
  349. $input_head .= '<th>'.$v.'</th>';
  350. }
  351. $head .= '</tr></thead>';
  352. $single_head .= '</tr></thead>';
  353. $input_head .= '</tr></thead>';
  354. $body = '<tbody>';
  355. $single_body = '<tbody>';
  356. $input_body = '<tbody>';
  357. if (!$group_attr) {
  358. $prefix = '[总价]:';
  359. if (!$update && $col_num <= 1) {
  360. $head = '';
  361. }
  362. if ($update) {
  363. $input .= '<input type="hidden" name="key" value="-1"/>';
  364. }
  365. $body .= '<tr>';
  366. if ($parent_goods) {
  367. $body .= '<td width="10">'.$parent_goods['name'].'</td>';
  368. }
  369. foreach ($set['col'] as $k1 => $v1) {
  370. if (!$update && strstr($v1, '^')) {
  371. continue;
  372. }
  373. $value = $this->getValue($k1, -1, $sku_value, $sku);
  374. if ($update) {
  375. if (strstr($v1, '|')) {
  376. $v1 = str_replace('|', '', $v1);
  377. $body .= '<td width="30">'.$value.'</td>';
  378. } else {
  379. $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'" value="'.$value.'"/></td>';
  380. }
  381. } elseif ($col_num > 1) {
  382. $body .= '<td width="30">'.$value.'</td>';
  383. } else {
  384. $body .= $value;
  385. }
  386. }
  387. $body .= '</tr>';
  388. } else {
  389. $prefix = '[组合价格]:';
  390. $group_attr = Dever::cartesian($group_attr);
  391. if ($sku_value) {
  392. foreach ($group_attr as $k => $v) {
  393. $key = array();
  394. foreach ($v['name'] as $k1 => $v1) {
  395. $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
  396. }
  397. $key = implode('_', $key);
  398. if (!isset($sku[$key])) {
  399. unset($group_attr[$k]);
  400. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  401. unset($group_attr[$k]);
  402. }
  403. }
  404. }
  405. $show = false;
  406. if ($group_attr) {
  407. foreach ($group_attr as $k => $v) {
  408. $body .= '<tr data-row="' .($k+1). '">';
  409. if ($parent_goods) {
  410. $body .= '<td>'.$parent_goods['name'].'</td>';
  411. }
  412. $key = $id = array();
  413. foreach ($v['name'] as $k1 => $v1) {
  414. $rows = 1;
  415. $body .= '<td width="50" rowspan="'.$rows.'">'.$v1.'</td>';
  416. $id[] = array
  417. (
  418. 'id' => $v['id'][$k1],
  419. 'attr_id' => $v['info_id'][$k1],
  420. );
  421. $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
  422. }
  423. $key = implode('_', $key);
  424. foreach ($set['col'] as $k1 => $v1) {
  425. if (!$update && strstr($v1, '^')) {
  426. continue;
  427. }
  428. $value = $this->getValue($k1, $key, $sku_value, $sku);
  429. if ($update) {
  430. if (strstr($v1, '|')) {
  431. $v1 = str_replace('|', '', $v1);
  432. $body .= '<td width="30">'.$value.'</td>';
  433. } else {
  434. $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  435. }
  436. } else {
  437. $body .= '<td width="30">'.$value.'</td>';
  438. }
  439. }
  440. if ($update) {
  441. $body .= '<input type="hidden" name="key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="attr['.$k.']">'.json_encode($id).'</textarea>';
  442. }
  443. $body .= '</tr>';
  444. }
  445. } else {
  446. $prefix = $head = $body = '';
  447. }
  448. }
  449. $body .= $input;
  450. $html = $prefix . $head . $body;
  451. if ($update) {
  452. $html = '<table class="layui-table">' . $html . '</table>';
  453. } else {
  454. $html = '<table class="layui-table">' . $html . '</table>';
  455. }
  456. if ($single_attr && $sku_value) {
  457. foreach ($single_attr as $k => $v) {
  458. $key = $v['info_id'] . '-' . $v['id'];
  459. if (!isset($sku[$key])) {
  460. unset($single_attr[$k]);
  461. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  462. unset($single_attr[$k]);
  463. }
  464. }
  465. }
  466. if ($single_attr) {
  467. $html = $html;
  468. foreach ($single_attr as $k => $v) {
  469. $id = array();
  470. $single_body .= '<tr data-row="' .($k+1). '">';
  471. if ($parent_goods) {
  472. $single_body .= '<td>'.$parent_goods['name'].'</td>';
  473. }
  474. $rows = 1;
  475. $single_body .= '<td width="100" rowspan="'.$rows.'">'. $v['parent_name'].'->'. $v['name'].'</td>';
  476. $id[] = array
  477. (
  478. 'id' => $v['id'],
  479. 'attr_id' => $v['info_id'],
  480. );
  481. $key = $v['info_id'] . '-' . $v['id'];
  482. foreach ($set['col'] as $k1 => $v1) {
  483. if (!$update && strstr($v1, '^')) {
  484. continue;
  485. }
  486. $value = $this->getValue($k1, $key, $sku_value, $sku);
  487. if ($update) {
  488. if (strstr($v1, '|')) {
  489. $v1 = str_replace('|', '', $v1);
  490. $single_body .= '<td width="30">'.$value.'</td>';
  491. } else {
  492. $single_body .= '<td width="30"><input type="text" class="layui-input" name="single_'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  493. }
  494. } else {
  495. $single_body .= '<td width="30">'.$value.'</td>';
  496. }
  497. }
  498. if ($update) {
  499. $single_body .= '<input type="hidden" name="single_key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="single_attr['.$k.']">'.json_encode($id).'</textarea>';
  500. }
  501. $single_body .= '</tr>';
  502. }
  503. $html = $html . '[单选价格]:<table class="layui-table">' . $single_head . $single_body . '</table>';
  504. }
  505. if ($input_attr && $sku_value) {
  506. foreach ($input_attr as $k => $v) {
  507. $key = array();
  508. foreach ($v['option'] as $k1 => $v1) {
  509. $key[] = $v1['price_key'];
  510. }
  511. $key = implode('_', $key);
  512. if (!isset($sku[$key])) {
  513. unset($input_attr[$k]);
  514. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  515. unset($input_attr[$k]);
  516. }
  517. }
  518. }
  519. if ($input_attr) {
  520. foreach ($input_attr as $k => $v) {
  521. if ($v['sell_compute'] == 2) {
  522. $v['sell_compute_type'] = '+';
  523. } elseif ($v['sell_compute'] == 3) {
  524. $v['sell_compute_type'] = '-';
  525. } else {
  526. $v['sell_compute_type'] = '*';
  527. }
  528. $id = array();
  529. $input_body .= '<tr data-row="' .($k+1). '">';
  530. if ($parent_goods) {
  531. $input_body .= '<td>'.$parent_goods['name'].'</td>';
  532. }
  533. $rows = 1;
  534. $key = $id = $name = array();
  535. foreach ($v['option'] as $k1 => $v1) {
  536. $id[] = array
  537. (
  538. 'id' => $v1['id'],
  539. 'attr_id' => $v1['info_id'],
  540. );
  541. $key[] = $v1['price_key'];
  542. $name[] = $v1['name'];
  543. }
  544. $key = implode('_', $key);
  545. $input_body .= '<td width="100" rowspan="'.$rows.'">'. $v['name'].'->'. implode($v['sell_compute_type'], $name).'</td>';
  546. $input_body .= '<td width="5"> >='.$v['sell_value'].'</td>';
  547. foreach ($set['col'] as $k1 => $v1) {
  548. if (!$update && strstr($v1, '^')) {
  549. continue;
  550. }
  551. $value = $this->getValue($k1, $key, $sku_value, $sku);
  552. if ($update) {
  553. if (strstr($v1, '|')) {
  554. $v1 = str_replace('|', '', $v1);
  555. $input_body .= '<td width="30">'.$value.'</td>';
  556. } else {
  557. $input_body .= '<td width="30"><input type="text" class="layui-input" name="input_'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  558. }
  559. } else {
  560. $input_body .= '<td width="30">'.$value.'</td>';
  561. }
  562. }
  563. if ($update) {
  564. $input_body .= '<input type="hidden" name="input_key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="input_attr['.$k.']">'.json_encode($id).'</textarea>';
  565. }
  566. $input_body .= '</tr>';
  567. }
  568. $html = $html . '[计算价]:<table class="layui-table">' . $input_head . $input_body . '</table>';
  569. }
  570. return $html;
  571. }
  572. private function create_table($head, $body)
  573. {
  574. $html = '<table class="layui-table">';
  575. }
  576. private function getValue($k1, $key, $sku_value, $sku)
  577. {
  578. $value = '';
  579. if ($k1 == 'min') {
  580. $value = 0;
  581. } else {
  582. $value = 0;
  583. }
  584. if ($key == -1) {
  585. if (isset($sku_value[-1]) && isset($sku_value[-1][$k1])) {
  586. $value = $sku_value[-1][$k1];
  587. } elseif (isset($sku[-1]) && isset($sku[-1][$k1])) {
  588. $value = $sku[-1][$k1];
  589. }
  590. } else {
  591. if (isset($sku[$key])) {
  592. if (isset($sku_value[$sku[$key]['id']][$k1])) {
  593. $value = $sku_value[$sku[$key]['id']][$k1];
  594. } elseif (isset($sku[$key][$k1])) {
  595. $value = $sku[$key][$k1];
  596. }
  597. }
  598. }
  599. return $value;
  600. }
  601. }