/// <summary> /// Call to shopify to get the list of products, available in shopify website. /// </summary> /// <param name="apiKey">pass apiKey used login in Shopify main portal</param> /// <param name="password">password used login in Shopify main portal</param> /// <param name="storeUrl">pass storeUrl created for the store Shopify main portal</param> /// <returns>Return list of products</returns> public static List <TrekWoAProductsPortal.Model.product> GetAllProducts(string apiKey, string password, string storeUrl) { List <TrekWoAProductsPortal.Model.product> products = null; try { dynamic shopify = new Shopify.Api(apiKey, password, storeUrl); var selectQuery = shopify.Products(); products = new List <Model.product>(); if (selectQuery != null) { products = new List <Model.product>(); foreach (var item in selectQuery.products) { TrekWoAProductsPortal.Model.product product = new TrekWoAProductsPortal.Model.product(); product.id = Convert.ToString(item.id); product.title = item.title; products.Add(product); } } } catch (Exception x) { MessageBox.Show(x.Message); } return(products); }
/// <summary> /// Call to Shopify api for get one product details based on product id. /// </summary> /// <param name="apiKey">pass apiKey used login in Shopify main portal</param> /// <param name="password">password used login in Shopify main portal</param> /// <param name="storeUrl">pass storeUrl created for the store Shopify main portal</param> /// <returns>Return a product based on product id, available on Shopify</returns> public static TrekWoAProductsPortal.Model.product GetProduct(string apiKey, string password, string storeUrl, string fullUrl = null) { TrekWoAProductsPortal.Model.product product = null; try { dynamic shopifyProductSelected = new Shopify.Api(apiKey, password, storeUrl, fullUrl); var IsProductSelected = shopifyProductSelected.Products(); if (IsProductSelected != null) { product = new Model.product() { id = Convert.ToString(IsProductSelected.product.id), title = IsProductSelected.product.title }; } } catch (Exception ex) { } return(product); }