/** * * @param $top 获取的产品个数 * @param $type 产品类型 * @return 获取产品信息的基本列表 * @return 同时获取相应产品的商家名称 */ public function getTopProductByType($top, $type) { $res = array(); $dao = new DaoProductBasicinfo(); $res = $dao->getTopBasicinfoByType($top, $type); if (!empty($res)) { $daoProduct = new DaoProduct(); $daoVendor = new DaoVendor(); $daoVendorInfo = new DaoVendorInfo(); for ($i = 0, $len = count($res); $i < $len; $i++) { $res[$i]['vendor_info'] = 0; $productId = (int) $res[$i]['product_id']; if (!empty($productId)) { $vendorIdList = $daoProduct->getVendorIdByProductId($productId); if (count($vendorIdList) == 1) { $vendor = $daoVendor->getVendorById((int) $vendorIdList[0]); if (!empty($vendor) && ($info_id = $vendor[0]['vendor_info_id']) != null) { $vendor_info = $daoVendorInfo->getVendorInfoById((int) $info_id); if (count($vendor_info) == 1) { $res[$i]['vendor_info'] = $vendor_info[0]; } } } } } } return $res; }