public IEnumerator GetProductDetail(string sku, ProductDownloadCallback callback) { bool toEnd = false; yield return(null); foreach (Category cat in catList) { foreach (CategoryProduct cp in cat.Products) { if (cp.sku == sku) { Product p = new Product(); p.category_id = cp.category_id; p.sku = sku; p.name = cp.sku; callback(p); toEnd = true; break; } } if (toEnd) { break; } } }
public IEnumerator DownloadProductDetail(string sku, ProductDownloadCallback callback) { WWW cases = new WWW(baseUrl + "/rest/V1/products/" + EncodeUriComponent(sku)); yield return(cases); string json = cases.text; Product result = JsonConvert.DeserializeObject <Product>(json); callback(result); }
//test public IEnumerator GetSubCategoryProductDetail(long subCategoryId, string sku, ProductDownloadCallback callback) { bool toEnd = false; yield return(null); int parentID = (int)(subCategoryId / 100); SubCategory scat = catList[parentID].SubCategorys[(int)(subCategoryId - parentID * 100)]; Debug.Log("GetSubCategoryProductDetail scat.Products.Count = " + scat.Products.Count); Debug.Log("sku = " + sku); foreach (CategoryProduct cp in scat.Products) { Debug.Log("cp.sku = " + cp.sku); if (cp.sku == sku) { Debug.Log("GetSubCategoryProductDetail return"); Product p = new Product(); p.category_id = cp.category_id; p.sku = sku; p.name = cp.sku; callback(p); toEnd = true; break; } } }
public void GetSubCategoryProductDetail(long sub_id, string sku, ProductDownloadCallback callback) { StartCoroutine(collector.GetSubCategoryProductDetail(sub_id, sku, callback)); }
// //test // public void GetSubCatAndProductsInCategory(long categoryId, Action<string> callback) // { // StartCoroutine(collector.GetSubCatAndProductsInCategory(categoryId, callback)); // } public void GetProductDetail(string sku, ProductDownloadCallback callback) { StartCoroutine(collector.GetProductDetail(sku, callback)); }
//test !!!!need to rewrite in the future public IEnumerator GetSubCategoryProductDetail(long subCategoryId, string sku, ProductDownloadCallback callback) { WWW cases = new WWW(baseUrl + "/magento/Json/Products/" + EncodeUriComponent(sku) + ".json"); yield return(cases); string json = cases.text; Product result = JsonConvert.DeserializeObject <Product>(json); callback(result); }