<?php /*获取卖家信用*/ $_user->credit; /*获取卖家好评率*/ $_user->goodRate; /*获取卖家ID*/ $_user->id; /*获取卖家昵称*/ $_user->nick; /*获取卖家注册时间*/ $_user->registrationDate; /获取卖家国家*/ $_user->country; /*获取卖家省份*/ $_user->province; /*获取卖家城市*/ $_user->city; ?>
<?php /*获取店铺ID*/ $_shop->id; /*获取店铺名称*/ $_shop->title; /*获取店铺简介*/ $_shop->introduction; /获取店铺公告*/ $_shop->bulletin; /*获取店铺ID*/ $_shop->id; /*获取店铺标题*/ $_shop->title; ?>
店铺类目获取通过ShopCategoryManager获取,ShopCategoryManager的说明如下:
1. 查询所有的店铺一级类目:queryAll
2. 查询店铺类目的所有子类目:querySubCategories
3. 根据店铺类目标识查询店铺类目:queryById
<?php $subCategories = $shopCategoryManager->querySubCategories($parentId); foreach($subCategories as $shopCategory){ echo "店铺类目名称是:".$shopCategory->name; } ?>
<?php $shopCategory = $shopCategoryManager->queryById($Id); echo "店铺类目名称是:".$shopCategory->name; ?>
设计师通过ItemManager获取宝贝数据,ItemManager的接口说明如下:
1. 根据关键字查询宝贝:queryByKeyword
2. 根据店铺类目ID来查询该类目下的宝贝: queryByCategory
3. 根据指定的宝贝Id查询对应的宝贝数据:queryById
4. 根据一组宝贝ID查询宝贝,返回的宝贝最大个数为20个:queryByIds
排序标识 | 说明 | 是否默认显示 |
---|---|---|
coefp | 人气宝贝升序排序 | 是 |
_coefp | 人气宝贝降序排序 | 否 |
hotsell | 热销宝贝升序排序 | 否 |
_hotsell | 热销宝贝降序排序 | 否 |
price | 以宝贝价格升序排序 | 否 |
_price | 以宝贝价格降序排序 | 否 |
newOn | 以最新上架宝贝升序排序 | 否 |
_newOn | 以最新上架宝贝降序排序 | 否 |
HotKeep | 以热门搜索升序排序 | 否 |
_HotKeep | 以热门搜索降序排序 | 否 |
<?php /*查询关键字为IPad的10个宝贝,按照热销降序排列*/ $items = $itemManager->queryByKeyword("Ipad","hotsell",10); foreach($items as $item){ echo "宝贝标题:". $item->title; echo "宝贝价格:". $item->price; } ?>
<?php /*根据类目ID查询10个宝贝,按照热销降序排序*/ $items = $itemManager->queryByCategory($categoryId,"hotsell",10); foreach($items as $item){ echo "宝贝标题:". $item->title; echo "宝贝价格:". $item->price; } ?>
<?php /*根据ID查询宝贝*/ $item = $itemManager->queryById($id); echo "宝贝标题:". $item->title; echo "宝贝价格:". $item->price; ?>
<?php /*根据ID列表查询宝贝*/ $ids = array(123456,654321); $items = $itemManager->queryByIds($ids,"hotsell"); foreach($items as $item){ echo "宝贝标题:". $item->title; echo "宝贝标题:". $item->price; } ?>
<?php /*根据ID查询宝贝*/ $item = $itemManager->queryById($id); echo "宝贝图片120x120". $item->getPicUrl(120); echo "宝贝图片220x220". $item->getPicUrl(220); ?>
<?php /*查询用户所有的友情链接*/ $friendLinks = $friendLinkManager->queryAllLinks(); foreach($friendLinks as $friendLink){ echo "友情链接:". $friendLink->title; } ?>
1. 生成宝贝详情页的URI: detailURI
<?php $uriManager->detailURI($item); ?>
2. 生成搜索列表页的URI: searchURI
<?php $uriManager->searchURI(); ?>
3. 生成当前用户的评价页面URI: rateURI
<?php $uriManager->rateURI(); ?>
4. 生成当前店铺介绍页面的URI: shopIntrURI
<?php $uriManager->shopIntrURI(); ?>
5. 生成店铺类目对应的URI:shopCategoryURI
<?php $uriManager->shopCategoryURI ($shopCategory); ?>
6. 生成收藏店铺URI:favoriteLink
<?php $uriManager-> favoriteLink(); ?>
7. 生成旺旺链接URI:contactTag(userNick)
<?php $uriManager-> contactTag ('nick'); ?>
$uriManager->supportTag 方法和参数详细介绍,提供了四种调用模式,单个参数模式,参数为客户旺旺的ID.
<?php echo $uriManager->supportTag("客服旺旺ID号"); ?>
<?php echo $uriManager->supportTag("客服旺旺ID号","请点击直接访问"); ?>
<?php echo $uriManager->supportTag("客服旺旺ID号","请点击直接访问",1); ?>
<?php echo $uriManager->supportTag("客服旺旺ID号","请点击直接访问",1,false); ?>
<?php /*生成宝贝详情页的URI*/ $itemURI = $uriManager->detailURI($item); ?>
<?php /*生成搜索列表页的URI*/ $searchURI = $uriManager->searchURI(); ?>
<?php /*生成评价页面的URI*/ $rateURI = $uriManager->rateURI(); ?>
<?php /*生成店铺介绍页面的URI*/ $shopIntroduction = $uriManager->shopIntrURI(); ?>
<?php /*生成店铺类目的URI*/ $uriManager->shopCategoryURI($shopCategory); ?>
<?php /*参数说明:此接口不需要参数,默认获取收藏当前店铺的URI*/ echo"生成收藏店铺URI:".$uriManager->favoriteLink(); ?>
<?php /*参数说明:此接口需要传递用户的旺旺名称*/ echo"生成旺旺链接URI:".$uriManager->contactTag('nickname'); ?>
宝贝数字id:auctionId
评价者昵称:raterNick
评价者头像:raterAvatar;支持"24x24","30x30","40x40","60x60","70x70","80x80","100x100","110x110","120x120","160x160",默认"160x160"
评价内容:feedback
评价时间:feedbackdate
好评数:goodCount
中评数:normalCount
差评数:badCount
总评数:total
评价信息获取通过rateManager获取,具体说明如下:
1、批量查询最多20个宝贝的单条评价信息:queryRates($auctionNumIds)
参数说明:宝贝数字id列表;数组形式转入;
业务规则说明:
a、返回最多20个宝贝的单条评价信息;如果超过20个,直接忽略请求,不拉取任何数据; b、评价筛选条件:获取每个商品最近的10条评价 取出字数大于20个字小于80个字的评价,随机选择一条返回 如果没有符合条件的评价,取字数最多的一条 c、1次页面渲染最多3次调用(接口调用可以分布在不同模块,但是总调用次数不超过3次/页);如果超过3次,则返回前3次调用的结果,其余忽略; d、接口始终返回非null;
使用实例
<?php $rate_items=$_MODULE['test_rate_items']; if(!$rate_items) echo "请选择宝贝"; else { $items=explode(',',$rate_items); //请确保$items为有效数字id列表,否则有可能导致模块渲染失败!!! $rates = $rateManager->queryRates($items); foreach($rates as $rate){ echo "评价者:".$rate->raterNick; echo "评价者头像:".$rate->getRaterAvatar('24'); echo " 评价详情:".$rate->feedback; echo " 评价时间:".$rate->feedbackdate; echo " 宝贝id:".$rate->auctionId; } } ?>
2、查询指定宝贝评价信息:queryAuctionRates($auctionNumId)
参数说明:宝贝数字id;请确保为有效数字id;
业务规则说明:
a、返回单个宝贝15条有内容的评价信息 b、1次页面渲染最多30次调用(接口调用可以分布在不同模块,但是总调用次数不超过30次/页);如果超过30次,则返回前30次调用的结果,其余忽略;; c、拉取评分较高的评价信息; d、不保证评论字数在某一个字数范围内 e、按照评价时间倒序排序; f、接口始终返回非null;
使用实例
<?php $rate_items=$_MODULE['test_rate_items']; if(!$rate_items) echo "请选择宝贝"; else { $items=explode(',',$rate_items); foreach($items as $item) { $rates = $rateManager->queryAuctionRates($item); foreach($rates as $rate) { echo "评价者:".$rate->raterNick; echo "评价者头像:".$rate->getRaterAvatar('24'); echo " 评价详情:".$rate->feedback; echo " 评价时间:".$rate->feedbackdate; echo " 宝贝id:".$rate->auctionId; } } } ?>
3、查询店铺当前收到的买家评价信息:queryShopRates()
参数说明:无
业务规则说明:
a、拉取店铺收到的20条买家评价信息 b、优先拉取评分高的评价,按照评价时间倒序排序; c、1次页面渲染最多1次调用(接口调用可以分布在不同模块,但是总调用次数不超过1次/页);如果超过1次,则返回前1次调用的结果,其余忽略; d、不保证评论字数在某一个字数范围内; e、接口始终返回非null;
使用实例:
<?php $rates = $rateManager->queryShopRates(); foreach($rates as $rate){ echo " 宝贝id:".$rate->auctionId; echo " 评价者:".$rate->raterNick; echo "评价者头像:".$rate->getRaterAvatar('24'); echo " 评价详情:".$rate->feedback; echo " 评价时间:".$rate->feedbackdate; } ?>
4、查询指定宝贝的评论数:queryRateCount($auctionNumId)
参数说明:宝贝数字id;确保有效宝贝id;
业务规则说明:
a、获取auctionNumId指定的宝贝,所拥有的主站好评数、中评数、差评数以及总评数 b、1次页面渲染最多30次调用(接口调用可以分布在不同模块,但是总调用次数不超过30次/页);如果超过30次,则返回前30次调用的结果,其余忽略;; c、接口允许返回null
使用实例:
<?php $rate_items=$_MODULE['test_rate_items']; if(!$rate_items) echo "请选择宝贝"; else { $items=explode(',',$rate_items); foreach($items as $item){ $count = $rateManager->queryRateCount($rate_item); if($count){ echo "好评数:".$count->goodCount; echo "中评数:".$count->normalCount; echo "差评数:".$count->badCount; } } } ?>
($openItemDOList);参数是宝贝列表$openItemDOList。
果为该宝贝的属性列表,类型为:List<String>。参数 openItemSkuDOList是一个宝贝的sku对象列表;skuProperty指的是要查询的属性名称。
<?php echo "-----测试批量查询-----"; $idList = Array('20','21'); $openItemDOList= $itemManager->queryByIds($idList,''); $skuLists = $itemManager->queryOpenSkuDOListByOpenItemDOList($openItemDOList); foreach($skuLists as $skuList){ foreach($skuList as $sku){ echo "sku的ID:".$sku->skuId; echo "sku的itemID:".$sku->itemId; echo "sku的数量:".$sku->quantity; echo "sku的价格:".$sku->price; echo "sku的图片url:".$sku->propertyImageUrl; $skuPropertyList = $sku->openItemSkuPropertiesDOList; echo "sku的属性:"; foreach($skuPropertyList as $skuProperty){ echo $skuProperty->propertyText." : ".$skuProperty->valueText; } } } ?>
<?php $skuLists = $itemManager->queryOpenSkuDOListByOpenItemDOList($openItemDOList); foreach($skuLists as $skuList){ $propertyList = $itemManager->getSkuProperties($skuList); foreach($propertyList as $property){ echo $property; } } ?>
<?php $skuLists = $itemManager->queryOpenSkuDOListByOpenItemDOList($openItemDOList); foreach($skuLists as $skuList){ $propertyList = $itemManager->getSkuProperties($skuList); foreach($propertyList as $property){ $propertyValueList = $itemManager->getSkuPropertyValues($skuList,$property); foreach($propertyValueList as $propertyValue){ echo $propertyValue; } } ?>
<?php $skuLists = $itemManager->queryOpenSkuDOListByOpenItemDOList($openItemDOList); foreach($skuLists as $skuList){ $picUrlList = $itemManager->getSkuPropertyPics($skuList); 或者 $picUrlList = $itemManager->getSkuPropertyPics($skuList,"310"); 或者 $picUrlList = $itemManager->getSkuPropertyPics($skuList,"310","310"); foreach($picUrlList as $picUrl){ echo $picUrl; } } ?>
<?php global $itemIds; if($_MODULE["itemss"]!=null){ $itemIds=explode(',',$_MODULE["itemss"]); //根据宝贝id列表批量查询宝贝对象列表 $openItemDOList= $itemManager->queryByIds($itemIds,''); //根据宝贝列表查询宝贝的sku信息,input:宝贝列表,output:sku列表的列表,如果 //宝贝列表中的某个宝贝不存在sku信息,则返回null值;如果参数:宝贝列表的数目 //超过20个时,则返回前20个宝贝的sku信息。 $skuLists = $itemManager->queryOpenSkuDOListByOpenItemDOList($openItemDOList); foreach($skuLists as $skuList){ //根据某个宝贝的sku列表信息,获取宝贝所具有的属性列表,一个宝贝有多条属性 $properties = $itemManager->getSkuProperties($skuList); foreach($properties as $property){ //根据宝贝属性查询该属性下所具有的值 $propertyValueList = $itemManager->getSkuPropertyValues($skuList,$property); echo $property .":"; foreach($propertyValueList as $propertyValue){ echo $propertyValue.","; } echo "<br>"; } echo "<br>"; //获取某个宝贝的属性图片列表 $picList = $itemManager->getSkuPropertyPics($skuList); foreach($picList as $pic){ echo $pic .","."<br>"; } } } ?>
$value= $_MODULE['paramName'];
$itemRates = $rateManager->parse($value);
foreach($itemRates->keySet() as $itemId) { $rates = $itemRates->get($itemId); foreach($rates as $rate) { echo '宝贝id:'.$rate->auctionId; echo '宝贝url'.$rate->auctionUrl; echo '评价者数字id:'.$rate->raterId; echo '评价者头像:'.$rate->getRaterAvatar('60'); echo '评价者昵称:'.$rate->raterNick; echo '评论者信用等级:'.$rate->raterStarImg; echo '评价者个人主页:'.$rate->raterUrl; echo '该宝贝的更多评价:'.$rate->moreFeedbackUrl; echo '评价内容:'.$rate->feedback; $pics = $rate->getRatePics('40'); foreach($pics as $pic) { echo '评价图片:'.$pic; } echo '评价时间:'.$rate->feedbackdate; } }
通过接口getRaterAvatar(size)获取完整头像地址;目前头像大小支持:"24x24","30x30","40x40","60x60","70x70","80x80","100x100","110x110","120x120","160x160"
通过接口getRaterPics(size)获取完整的评价图片列表;建议图片大小使用"40x40"或者"400x400";目前大小支持:"24x24","30x30","40x40","60x60","70x70","80x80","100x100","110x110","120x120","160x160","400x400"
在引入宝贝评价选择器的模块中引入新的参数类型,具体详见module.xml部分代码
...... <parameters> <group title="选择器组"> <section folded="false" title="选择器部分"> <param ptype="itemRate" name="test_item_rate" label="宝贝评价选择器" formType="itemRateForm" description="宝贝评价选择器"></param> </section> </group> </parameters> ......
<?php /** * 开始设计PHP页面 */ $value = $_MODULE['test_item_rate']; if($value) { $itemRates = $rateManager->parse($value); foreach($itemRates->keySet() as $itemId) { $rates = $itemRates->get($itemId); foreach($rates as $rate) { echo '宝贝id:'.$rate->auctionId.'<br/>'; echo '宝贝url'.$rate->auctionUrl; echo '评价者数字id:'.$rate->raterId; echo '评价者头像:'.$rate->getRaterAvatar('60'); echo '评价者昵称:'.$rate->raterNick; echo '评论者信用等级:'.$rate->raterStarImg; echo '评价者个人主页:'.$rate->raterUrl; echo '该宝贝的更多评价:'.$rate->moreFeedbackUrl; echo '评价内容:'.$rate->feedback; echo '评价图片:'.$rate->getRatePics('40'); foreach($rate->getRatePics('40') as $ratePic) { echo '$ratePic'; } echo '评价时间:'.$rate->feedbackdate; } } } ?>