Recommendation Widget'larının Web Sitesine Yerleştirilmesi
Web sitenizde göstereceğiniz belirli bir widget'ın JavaScript kodunu almak için; Recommend> Web Recommendation yolunu takip edin.
Widget'ların listesini aşağıda gösterildiği gibi görmelisiniz:
Kod almak istediğiniz Widget Adının yanındaki Düzenle(Edit)'yi tıklayın. Aşağıda gösterilen ekrana benzer bir ekran göreceksiniz. Şablon kodu ekranın alt kısmındadır. Kodu kopyalayıp yalnızca öneri widget'ı yer almasını istediğiniz sayfalara yapıştırmanız yeterlidir.
Bir widget'ın yalnızca önerilen bir ürün dizisini döndürdüğünü ve web sitenizde ilgili önerileri görüntülemek için gereksinimlerinize göre uygulamanız gerektiğini unutmayın.
<script> var vl = new Visilabs(); vl.AddParameter("json",true); vl.Suggest(1,null,null,TopSellers); function TopSellers(dataArr){ if (dataArr.length>0){ $.each(dataArr,function(index,element){ $("#content").append("<div><a href='"+element.dest_url+"'> <img src='"+element.img+"'></a>"+ "<p>Title: "+element.title+"</p>+ "<p>Org.Fiyat"+element.price+"</p>"+ "<p>Disc.Fiyat"+element.dprice+"</p></div>"); }); } </script
"title": "Product Name", "img": "Product Image URL", "code": "Product Code", "target": "_self", "dest_url": "www.website.com/prodpage?OM.zn=widget_adi&OM.zpc=productcode", "brand": "product brands", "price": 18.5000, // original price of product "dprice": 9.0000, // discounted price of product "cur": "USD", // original price currency "rating": 0, // customer rating of product "comment": 0, // number of comments by customers "freeshipping": false, // "samedayshipping": false, "attr1": "", // product attribute (can be anything like color,size) "attr2": "", "attr3": "", "attr4": "", "attr5": ""
Recommendation Widgetlarında Filtreleme
Öneri widgetları için filtreleme yapabilirsiniz.
Name, Category, ProductName, Brand, Color, Material, Gender, AgeGroup, Attribute1, Attribute2, Attribute3, Attribute4, Attribute5, FreeShipping ( “true” veya “false” ), ShippingOnSameDay (“true” veya “false”)
new VL_OfferFilter("Name",VLOfferFilterType.Include,"Value");
- Value: Buradaki değerlerin içeriği ürün dosyasından gelir. Filtreleme değeri verirken ürün dosyasında gönderilen değer ile aynı verilmelidir.
- Type: Filtre tipi olarak VLOfferFilter.Include ve VLOfferFilter.Exclude değerleri alır. Verilen değere göre ürünlerin getirilip getirilmeyeceğini belirler.
<script> var arrFilter = []; var filterColor = new VL_OfferFilter("COLOR", VL_OfferFilterType.Include, "Mavi"); var filterBrand = new VL_OfferFilter("BRAND", VL_OfferFilterType.Include, "Nike"); arrFilter.push(filterColor); arrFilter.push(filterBrand); var vl = new Visilabs(); vl.AddParameter("json",true); vl.Suggest(ZoneID,null,ViewedProductCode,callBack,null,arrFilter); </script>
Recommendation Widget'larının Mobil Uygulamaya Yerleştirilmesi
Android ve iOS mobil uygulamanızda, kişiye özel ürün önerileri göstermeniz için gerekli dokümanları bu bölümde bulabilirsiniz.
Android – In App
Bir VisilabsTargetRequest nesnesi oluşturun ve VisilabsTargetRequest nesnesinin executeAsync yöntemini çağırın.
ZoneID her uygulama için farklıdır, bu nedenle destek için RMC ekibi ile iletişime geçiniz. "Alternatif Ürünler" gibi öneri widgetları, ürün kodunun bir parametre olarak görülmesini gerektirir.
callback fonksiyonunun spesifikasyonu şöyledir:
VisilabsTargetRequest targetRequest = Visilabs.CallAPI().buildTargetRequest(zoneID, "productCode"); targetRequest.executeAsync(callback);
Ayrıca, filtreleri ve ek parametreleri geçirebileceğiniz bir overload buildTargetRequest yöntemi bulunmaktadır.
List filters = new ArrayList<VisilabsTargetFilter>(); HashMap<String,String> properties = new HashMap<String, String>(); properties.put("OM.extra", "Extra Value"); VisilabsTargetFilter f = new VisilabsTargetFilter(); f.setAttribute("attr1"); f.setFilterType("0"); // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". f.setValue("value"); filters.add(f); f = new VisilabsTargetFilter(); f.setAttribute("attr2"); f.setFilterType("1"); // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". f.setValue("value"); filters.add(f); VisilabsTargetRequest targetRequest = Visilabs.CallAPI().buildTargetRequest(zoneID, "productCode", properties, filters); targetRequest.executeAsync(callback);
Talep tamamlandıktan sonra, talebin başarı ya da başarısızlık durumuna bağlı olarak callback fonksiyonu çağrılır, bu nedenle ihtiyaçlarınıza göre callback fonksiyonlarını aşağıda gösterildiği gibi kodlamanız gerekir:
VisilabsTargetCallback callback = new VisilabsTargetCallback() { @Override public void success(VisilabsResponse response) { try{ JSONArray array = response.getArray(); if(array != null) { ArrayList<Product> recommendations = new ArrayList<>(); for (int i = 0; i < array.length(); i++) { JSONObject obj = (JSONObject)array.get(i); Product product = new Product(); product.setProductCode(obj.getString("code")); product.setProductName(obj.getString("title")); product.setMediumImageUrl(obj.getString("img")); product.setProductURL(obj.getString("dest_url")); product.setBrand(obj.getString("brand")); product.setOriginalPrice(obj.getDouble("price")); product.setDiscountedPrice(obj.getDouble("dprice")); product.setCurrency(obj.getString("cur")); product.setDiscountCurrency(obj.getString("dcur")); product.setFreeShipping(obj.getBoolean("freeshipping")); product.setShippingOnSameDay (obj.getBoolean("samedayshipping")); product.setRating(obj.getInt("rating")); product.setComment(obj.getInt("comment")); product.setDiscountRate(obj.getDouble("discount")); product.setAttr1(obj.getString("attr1")); product.setAttr2(obj.getString("attr2")); product.setAttr3(obj.getString("attr3")); product.setAttr4(obj.getString("attr4")); product.setAttr5(obj.getString("attr5")); recommendations.add(product); } } }catch (Exception ex){ showToast(ex.getMessage()); Log.e(LOG_TAG, ex.getMessage(), ex); } } @Override public void fail(VisilabsResponse response) { showToast(response.getErrorMessage()); Log.d(LOG_TAG, rawResponse); } };
iOS – In App
Bir VisilabsTargetRequest nesnesi oluşturun:
VisilabsTargetRequest *request=[[Visilabs callAPI] buildTargetRequest: @"ZoneID" withProductCode: @"ProductCode"];
let targetRequest = Visilabs.callAPI().buildTargetRequest("ZoneID", withProductCode: "ProductCode")
Ayrıca, filtreleri ve ek parametreleri geçirebileceğiniz bir overload buildTargetRequest yöntemi bulunmaktadır:
NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; NSMutableArray *filters = [[NSMutableArray alloc] init]; [dic setObject:@"Extra Value" forKey:@"OM.extra"]; VisilabsTargetFilter *filter1 = [[VisilabsTargetFilter alloc] init]; filter1.attribute = @"attr1"; filter1.value = @"val"; filter1.filterType = @"1"; // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". [filters addObject:filter1]; VisilabsTargetFilter *filter2 = [[VisilabsTargetFilter alloc] init]; filter2.attribute = @"attr2"; filter2.value = @"val"; filter2.filterType = @"0"; // There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". [filters addObject:filter2]; VisilabsTargetRequest *request=[[Visilabs callAPI] buildTargetRequest: @"ZoneID" withProductCode: @"ProductCode" withProperties:dic withFilters:filters];
let zoneID = "9" let dic = NSMutableDictionary() dic["OM.extra"] = "Extra Value"; let filters = NSMutableArray() let filter1 = VisilabsTargetFilter() filter1.attribute = "attr1" filter1.filterType = "1"// There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". filter1.value = "val" filters.add(filter1) let filter2 = VisilabsTargetFilter() filter2.attribute = "attr2" filter2.filterType = "0"// There are 2 filter types: Include and Exclude. For Include pass "0", for Exclude pass "1". filter2.value = "val" filters.add(filter2) let targetRequest = Visilabs.callAPI().buildTargetRequest("ZoneID", withProductCode: "ProductCode", withProperties:dic, with:filters)
Talep tamamlandıktan sonra, talebin başarı ya da başarısızlık durumuna bağlı olarak callback fonksiyonu çağrılır, bu nedenle ihtiyaçlarınıza göre callback fonksiyonlarını aşağıda gösterildiği gibi kodlamanız gerekir:
void (^ successBlock)(VisilabsResponse *) = ^(VisilabsResponse * response) { NSLog(@"Response: %@", response.rawResponseAsString); NSArray *parsedArray = [response responseArray]; if(parsedArray){ for (NSObject * object in parsedArray) { if([object isKindOfClass:[NSDictionary class]]){ NSDictionary *product = (NSDictionary*)object; NSString *title = [product objectForKey:@"title"]; NSString *img = [product objectForKey:@"img"]; NSString *code = [product objectForKey:@"code"]; NSString *destURL = [product objectForKey:@"dest_url"]; NSString *brand = [product objectForKey:@"brand"]; double price = [[product objectForKey:@"price"] doubleValue]; double discountedPrice = [[product objectForKey:@"dprice"] doubleValue]; NSString *currency = [product objectForKey:@"cur"]; NSString *discountCurrency = [product objectForKey:@"dcur"]; int rating = [[product objectForKey:@"rating"] intValue]; int comment = [[product objectForKey:@"comment"] intValue]; double discount = [[product objectForKey:@"discount"] doubleValue]; BOOL freeShipping = [[product objectForKey:@"freeshipping"] boolValue]; BOOL sameDayShipping = [[product objectForKey:@"samedayshipping"] boolValue]; NSString *attr1 = [product objectForKey:@"attr1"]; NSString *attr2 = [product objectForKey:@"attr2"]; NSString *attr3 = [product objectForKey:@"attr3"]; NSString *attr4 = [product objectForKey:@"attr4"]; NSString *attr5 = [product objectForKey:@"attr5"]; } } } }; void (^ failBlock)(VisilabsResponse *) =^(VisilabsResponse * response){ NSLog(@"Failed to call. Response = %@", [actFailRes.error description]); };
let successBlock:(VisilabsResponse!) -> Void = {response in print("Response:\(response.rawResponseAsString)") for object:AnyObject in response.responseArray{ if(object.isKindOfClass(NSDictionary)){ let productObject = object as! NSDictionary; let title = productObject.objectForKey("title") as! String let img = productObject.objectForKey("img") as! String let code = productObject.objectForKey("code") as! String let dest_url = productObject.objectForKey("dest_url") as! String let brand = productObject.objectForKey("brand") as! String let price = productObject.objectForKey("price") as! Double let discountedPrice = productObject.objectForKey("dprice") as! Double let currency = productObject.objectForKey("cur") as! String let discountCurrency = productObject.objectForKey("dcur") as! String let rating = productObject.objectForKey("rating") as! Int let comment = productObject.objectForKey("comment") as! Int let discount = productObject.objectForKey("discount") as! Double let freeShipping =productObject.objectForKey("freeshipping") as! Bool let sameDayShipping=productObject.objectForKey("samedayshipping") as! Bool let attr1 = productObject.objectForKey("attr1") as! String let attr2 = productObject.objectForKey("attr2") as! String let attr3 = productObject.objectForKey("attr3") as! String let attr4 = productObject.objectForKey("attr4") as! String let attr5 = productObject.objectForKey("attr5") as! String } } } let failBlock: (VisilabsResponse!) -> Void = {response in VisilabsHelper.targetLog(response.targetURL) print("Visilabs target call failed.Error=\(response.rawResponseAsString)") }
Ana Başlık: RMC'den Veri Aktarımı