WooCommerce.NET
WooCommerce.NET copied to clipboard
I can't retrieve the stock code of the products.
Hello everyone;
How can i listing all SKU?
solved
@palmeItGit please paste your solution in case some one needs it. Thanks
Hi! you guessed it, I don't remember :) but I found a code like this: Firstly you must (get all product(s) / filtered product(s) after than
private async Task<bool> CheckExistOnWoo(string ArtikelNr)
{
//First step get source products data
bool isExist = false;
RestAPI rest = new RestAPI(webConnecs.StoreAddress, webConnecs.Key, webConnecs.Secret, jsonDeserializeFilter: trimstr);
WCObject wc = new WCObject(rest);
List<Product> products = new List<Product>();
#region GetProductWithIdFromWeb
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("per_page", "100");
dictionary.Add("sku", ArtikelNr);
int pageNumber = 1;
dictionary.Add("page", pageNumber.ToString());
bool endWhile = false;
while (!endWhile)
{
var productsTemp = await wc.Product.GetAll(dictionary);
if (productsTemp.Count > 0)
{
products.AddRange(productsTemp);
pageNumber++;
dictionary["page"] = pageNumber.ToString();
}
else
{
endWhile = true;
}
}
#endregion
//Now you can check sku data...
foreach (Product p in products)
{
if (p.sku == ArtikelNr)
{
isExist = true;
break;
}
}
return isExist;
}
i hope you can found a sloution...
Nice work. Thanks again for the update.