function GetProductItemInfoList($styleId)
{
global $ClassPb;
global $conn_59;
$arr = explode(',',$styleId);
$arrCount = count($arr);
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = $doc->createElement("Items");
$doc->appendChild($root);
for ( $i = 0; $i < $arrCount; $i++)
{
$ret = $this->GetProductByStyleId($arr[$i], true);
$product_count = mysql_num_rows($ret);
if ($product_count >= 1)
{
while ($myrow = mysql_fetch_array($ret))
{
$item = $doc->createElement("Item");
//商品详情
$itemId = $doc->createElement("ItemId");
$itemId->setAttribute("desc","商品编号");
$itemId->appendChild($doc->createTextNode($myrow["StyleId"]));
$title = $doc->createElement("Title");
$title ->setAttribute("desc","商品名称");
$title->appendChild($doc->createTextNode($myrow["Title"]));
$styleId = $doc->createElement("StyleId");
$styleId ->setAttribute("desc","款式号");
$styleId->appendChild($doc->createTextNode($myrow["StyleId"]));
$brandText = $doc->createElement("BrandText");
$brandText ->setAttribute("desc","品牌文本");
$brandText->appendChild($doc->createTextNode($myrow["BrandText"]));
$categoryText = $doc->createElement("CategoryText");
$categoryText ->setAttribute("desc","分类文本");
$categoryText->appendChild($doc->createTextNode($myrow["CategoryText"]));
$bagSize = $doc->createElement("BagSize");
$bagSize ->setAttribute("desc","包体尺寸");
$bagSize->appendChild($doc->createTextNode($myrow["Size"]));
$weight = $doc->createElement("Weight");
$weight ->setAttribute("desc","重量");
$weight->appendChild($doc->createTextNode($myrow["Weight"]));
$upShelfTime = $doc->createElement("UpShelfTime");
$upShelfTime ->setAttribute("desc","上架时间");
$upShelfTime->appendChild($doc->createTextNode($myrow["UpShelfTime"]));
//产品
$products = $doc->createElement("Products");
$ret_prod = $this->GetProductByStyleId($arr[$i], false);
while ($myprod = mysql_fetch_array($ret_prod))
{
$product = $products->appendChild($doc->createElement("Product"));
$productId = $product->appendChild($doc->createElement("ProductId"));
$productId ->setAttribute("desc","商品编号");
$productId->appendChild($doc->createTextNode($myprod["ProductId"]));
$marketPrice = $product->appendChild($doc->createElement("MarketPrice"));
$marketPrice ->setAttribute("desc","市场价");
$marketPrice->appendChild($doc->createTextNode($myprod["MarketPrice"]));
$salePrice = $product->appendChild($doc->createElement("SalePrice"));
$salePrice ->setAttribute("desc","销售价");
$salePrice->appendChild($doc->createTextNode($myprod["SalePrice"]));
$colorText = $product->appendChild($doc->createElement("ColorText"));
$colorText ->setAttribute("desc","颜色文本");
$colorText->appendChild($doc->createTextNode($myprod["ColorText"]));
//大图
$largeImages = $product->appendChild($doc->createElement("LargeImages"));
//小图
$smallImages = $product->appendChild($doc->createElement("SmallImages"));
$large_ret = $this->GetProductInfoItemImg($myprod["ProductId"], 12);
while ($mylarge = mysql_fetch_array($large_ret))
{
$largeImage = $largeImages->appendChild($doc->createElement("LargeImage"));
$largeImage->appendChild($doc->createTextNode("http://image.yzy.com/" . $myprod["ProductId"] . "/" . $mylarge["LevelId"] . "/1024/1024/p.jpg"));
$smallImage = $smallImages->appendChild($doc->createElement("SmallImage"));
$smallImage->appendChild($doc->createTextNode("http://image.yzy.com/" . $myprod["ProductId"] . "/" . $mylarge["LevelId"] . "/62/62/p.jpg"));
}
//颜色图
$colorImage = $product->appendChild($doc->createElement("ColorImage"));
$colorImage->appendChild($doc->createTextNode("颜色图"));
//主图
$listImage = $product->appendChild($doc->createElement("ListImage"));
$listImage->appendChild($doc->createTextNode("主图"));
//模特图
$modelImages = $product->appendChild($doc->createElement("ModelImages"));
$modelImage = $modelImages->appendChild($doc->createElement("ModelImage"));
$modelImage->appendChild($doc->createTextNode("模特图"));
}
//属性
$attributes = $doc->createElement("Attributes");
$attr_ret = $this->GetProductAttributesList($myrow["ProductId"]);
while ($prod_attribute = mysql_fetch_row($attr_ret))
{
$attribute = $attributes->appendChild($doc->createElement("Attribute"));
$attribute->setAttribute("name","$prod_attribute[0]");
$attribute->setAttribute("value","$prod_attribute[1]");
}
//模特图
$modelImages = $doc->createElement("ModelImages");
$modelImage = $modelImages->appendChild($doc->createElement("ModelImage"));
$modelImage->appendChild($doc->createTextNode("模特图root"));
// 产品模特图
$productImages = $doc->createElement("ProductImages");
$productImage = $productImages->appendChild($doc->createElement("ProductImage"));
$productImage->appendChild($doc->createTextNode("产品模特图root"));
$content = $doc->createElement("Content");
$content ->setAttribute("desc","商品描述");
$cdata = $content->appendChild($doc->createCDATASection($myrow["Content"]));
$content->appendChild($cdata);
//商品详情
$item->appendChild($itemId);
$item->appendChild($title);
$item->appendChild($styleId);
$item->appendChild($brandText);
$item->appendChild($categoryText);
$item->appendChild($bagSize);
$item->appendChild($weight);
$item->appendChild($upShelfTime);
//产品
$item->appendChild($products);
//属性和内容
$item->appendChild($attributes);
$item->appendChild($modelImages);
$item->appendChild($productImages);
$item->appendChild($content);
$root->appendChild($item);
}
$ClassPb->FreeResource($ret);
}
}
$xmlString = $doc->saveXML();
//输出XML字符串
header('Content-Type: text/xml; charset=utf-8');
return $xmlString;
}