get(); foreach ($options as &$option) { $options->withhold_stock = $option->withhold_stock; } $specs = []; $html = ''; if (count($options) > 0) { $specitemids = explode("_", $options[0]['specs']); foreach ($specitemids as $itemid) { foreach ($allSpecs as $spec) { $specItems = $spec['items']; foreach ($specItems as $specItem) { if ($specItem['id'] == $itemid) { $specs[] = $spec; break; } } } } $html .= ''; $html .= ''; $html .= ''; $specs_len = count($specs); $newlen = 1; $h = []; $rowspans = []; for ($i = 0; $i < $specs_len; $i++) { $html .= ""; $itemlen = count($specs[$i]['items']); if ($itemlen <= 0) { $itemlen = 1; } $newlen *= $itemlen; $h = array(); for ($j = 0; $j < $newlen; $j++) { $h[$i][$j] = []; } $l = count($specs[$i]['items']); $rowspans[$i] = 1; for ($j = $i + 1; $j < $specs_len; $j++) { $rowspans[$i] *= count($specs[$j]['items']); } } $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; //$html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; for ($m = 0; $m < $specs_len; $m++) { $k = 0; $kid = 0; $n = 0; for ($j = 0; $j < $newlen; $j++) { $rowspan = $rowspans[$m]; if ($j % $rowspan == 0) { $h[$m][$j] = array( "html" => "", "id" => $specs[$m]['items'][$kid]['id'] ); } else { $h[$m][$j] = array( "html" => "", "id" => $specs[$m]['items'][$kid]['id'] ); } $n++; if ($n == $rowspan) { $kid++; if ($kid > count($specs[$m]['items']) - 1) { $kid = 0; } $n = 0; } } } $hh = ""; for ($i = 0; $i < $newlen; $i++) { $hh .= ""; $ids = []; for ($j = 0; $j < $specs_len; $j++) { $hh .= $h[$j][$i]['html']; $ids[] = $h[$j][$i]['id']; } $ids = implode("_", $ids); $val = [ "id" => "", "title" => "", "stock" => "", "withhold_stock" => "", "cost_price" => "", "product_price" => "", "market_price" => "", "weight" => "", "volume", 'virtual' => '', "red_price" => '', 'thumb' => '', ]; foreach ($options as $option) { if ($ids === $option['specs']) { $val = [ "id" => $option['id'], "title" => $option['title'], "stock" => $option['stock'], "withhold_stock" => $option['withhold_stock'], "cost_price" => $option['cost_price'], "product_price" => $option['product_price'], "market_price" => $option['market_price'], "goods_sn" => $option['goods_sn'], "product_sn" => $option['product_sn'], "weight" => $option['weight'], "volume" => $option['volume'], 'virtual' => $option['virtual'], 'red_price' => $option['red_price'], 'thumb' => $option['thumb'], 'url' => yz_tomedia($option['thumb']), //'option_ladder' => unserialize($o['option_ladders']) ]; break; } } $hh .= ''; //$hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; //$hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; } $html .= $hh; $html .= "
" . $specs[$i]['title'] . "
库存
预扣库存
市场价格
销售价格
成本价格
红包价格
商品编码
商品条码
重量(克)
体积(m³)
点击图片上传
推荐(100*100)
" . $specs[$m]['items'][$kid]['title'] . "
'; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= ''; $hh .= '
"; } return $html; } }