Beispiel #1
0
        internal static IEnumerable <ShopifyProduct> GetShopifyAllProduct(ShopifyProductService shopifyProductService, string fields = null)
        {
            var listProduct = default(Task <IEnumerable <ShopifyProduct> >);
            var allProducts = new List <ShopifyProduct>();
            var page        = 1;

            do
            {
                ShopifyCall.ExecuteCall(delegate()
                {
                    listProduct = shopifyProductService.ListAsync(new ShopifyProductFilterOptions
                    {
                        PublishedStatus = "any",
                        Limit           = 250,
                        Page            = page,
                        Fields          = fields
                    });

                    listProduct.Wait();
                });

                allProducts.AddRange(listProduct.Result);

                page++;
            }while (listProduct.Result.Count() == 250);

            return(allProducts);
        }
Beispiel #2
0
        public static async Task<long> GetProductId()
        {
            if (ProductId.HasValue)
            {
                return ProductId.Value;
            }

            var service = new ShopifyProductService(Utils.MyShopifyUrl, Utils.AccessToken);
            var products = await service.ListAsync(new Filters.ShopifyProductFilter()
            {
                Limit = 1,
                Fields = "id"
            });
            
            ProductId = products.First().Id;

            return ProductId.Value;
        }
Beispiel #3
0
        internal static ShopifyProduct GetProductOnShopify(ShopifyProductService shopifyProductService, string handle)
        {
            var shopifyProduct = default(ShopifyProduct);

            ShopifyCall.ExecuteCall(delegate()
            {
                var task = shopifyProductService.ListAsync(new ShopifyProductFilterOptions
                {
                    Handle = handle
                });

                task.Wait();

                shopifyProduct = task.Result.FirstOrDefault();
            });

            return(shopifyProduct);
        }
Beispiel #4
0
        public static async Task <long> GetProductId()
        {
            if (ProductId.HasValue)
            {
                return(ProductId.Value);
            }

            var service  = new ShopifyProductService(Utils.MyShopifyUrl, Utils.AccessToken);
            var products = await service.ListAsync(new Filters.ShopifyProductFilter()
            {
                Limit  = 1,
                Fields = "id"
            });

            ProductId = products.First().Id;

            return(ProductId.Value);
        }