Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product.Variations count is zero for ~90% of products with WooCommerce 6.6.1 update #698

Open
JayMoorhouse opened this issue Jul 5, 2022 · 2 comments

Comments

@JayMoorhouse
Copy link

JayMoorhouse commented Jul 5, 2022

Make sure you have included the below details when open an issue. Thank you.

Wordpress version, WooCommerce version and WooCommerce.NET version

  • We updated Wordpress core 5.9.2 -> 6.0 and WooCommerce 6.3.1->6.6.1

Steps to replicate the issue
The below method is used to get a list of published products:

public async Task<List<Product>> GetPublishedProducts()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("per_page", "100");
            int pageNumber = 1;
            dic.Add("page", pageNumber.ToString());
            dic.Add("status", "publish");
            List<Product> products = new List<Product>();
            bool endWhile = false;
            while (!endWhile)
            {
                var productsTemp = await _WCObject.Product.GetAll(dic);
                if (productsTemp.Count > 0)
                {
                    products.AddRange(productsTemp);
                    pageNumber++;
                    dic["page"] = pageNumber.ToString();
                }
                else
                {
                    endWhile = true;
                }
            }
            return products;
        }

Then, iterating the products, I check for variations so I can grab them too:

foreach (var product in products)

            {

                if (product.variations != null && product.variations.Count > 0)

                { ...

As of our WooCommerce update (above), the total amount of variable products pulled from our production environment went down from 577 to 29. The simple products are unchanged. The above check is showing product.variations.Count is zero for products that definitely have variations in WooCommerce.

Details of the error message if there is any
N/A

Any insight would be appreciated. I don't know why 49 are still working; at face value they don't have any differences with the ones that aren't.

EDIT
I'm using v0.8.2. I just updated to v0.8.4 and I'm testing--will follow up ASAP

@JayMoorhouse
Copy link
Author

Update: v0.8.4 has the same issue. I will revert WooCommerce version, but I'd still like to properly understand this issue.

@JayMoorhouse JayMoorhouse changed the title Product.Variations count is zero for ~90% of products as of July 1 2022 Product.Variations count is zero for ~90% of products with WooCommerce 6.6.1 update Jul 5, 2022
@JayMoorhouse
Copy link
Author

JayMoorhouse commented Jul 5, 2022

Update: _WCObject.Product.Variations.GetAll still works and returns variations on a product that has variations. Just odd that the Product.Variations.Count is 0. Now I have to run it on every product instead of only the ones that has variation.count > 0 which is fine, but obviously a lot worse for performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant