示例#1
0
        public static async Task <List <QuantityUpdate> > GetProductsToUpdateAsync(GetProductsAsyncDelegate getNextProductPageAsync, Dictionary <string, int> skusQuantities, int pageSize)
        {
            var productsToUpdate = new List <QuantityUpdate>();

            for (var page = 1; ; page++)
            {
                var pageFilter         = EndpointsBuilder.CreateGetPageAndLimitFilter(new WooCommerceCommandConfig(page, pageSize));
                var productsWithinPage = await getNextProductPageAsync(pageFilter);

                if (!productsWithinPage.Any())
                {
                    break;
                }
                foreach (var product in productsWithinPage.Where(p => p.Id != null))
                {
                    GetProductToUpdate(skusQuantities, product, productsToUpdate);
                }
            }
            return(productsToUpdate);
        }
示例#2
0
        public static async Task GetProductsAndVariationsToUpdateAsync(GetProductsAsyncDelegate getNextProductPageAsync, Func <int, Task <IEnumerable <WooCommerceVariation> > > getVariationsAsync, Dictionary <string, int> skusQuantities, int pageSize, List <QuantityUpdate> productsToUpdate, Dictionary <ProductId, IEnumerable <QuantityUpdate> > variationsToUpdate)
        {
            for (var page = 1; ; page++)
            {
                var pageFilter         = EndpointsBuilder.CreateGetPageAndLimitFilter(new WooCommerceCommandConfig(page, pageSize));
                var productsWithinPage = await getNextProductPageAsync(pageFilter);

                if (!productsWithinPage.Any())
                {
                    break;
                }
                foreach (var product in productsWithinPage.Where(p => p.Id != null))
                {
                    GetProductToUpdate(skusQuantities, product, productsToUpdate);

                    if (product.HasVariations)
                    {
                        GetVariationsToUpdate(skusQuantities, await getVariationsAsync(product.Id.Value), product.Id.Value, variationsToUpdate);
                    }
                }
            }
        }