• Resolved ellimstom

    (@ellimstom)


    Hi,

    I have a shop running WC. All the products are created with a REST API call and mostly have a category and a subcategory.

    In the example link, I cannot display products with subcategory “futs-6l-perfectdraft” in the subcategory archive page (only 4 on 10) but if you go on the primary category “bieres-au-fut”, all 10 perfectdraft products show up (maybe my Website has been drinking too much beer ?? ).

    If I edit and save manually a product, it shows up in the “futs-6l-perfectdraft” subcategory archive page…

    I tried with Twenty twenty theme, nothing changed. I used “Appearance > Customize > Woocommerce > Product catalog” and set shop display: category only – category display: subcategory and products.

    I asked Woocommerce support and they wasn’t able to help (they think it may be a wrong api call). They told me to try here on the forum. I installed the WC library with composer and POST my products with API as explained in the doc on github.

    Do you have any idea about what’s going on ? It really looks like a bug to me…

    Thanks a lot.

    Bernard

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @ellimstom

    I just tested creating a product using the API and it works as expected. The issue is indeed likely with the code used to make the request or something regarding the hosting environment.

    You can review working examples shown within the API docs to compare to the code being used:

    https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product

    My suggestion would be to contact the person who created the request or seek help from another developer. You might want to check out our advanced WooCommerce Community in Slack:

    https://woocommerce.com/community-slack/

    or the Advanced WooCommerce Facebook Group:

    https://www.facebook.com/groups/advanced.woocommerce/

    There are many developers gathered in those communities.

    Thread Starter ellimstom

    (@ellimstom)

    Hi @johndcoy,

    Thank you for your help…

    I’ve just found out something new:
    – I export products from “Wines” category
    – I edit the CSV file to replace “Wines” with “Wines, Wines > Other wines”
    – I import my CSV and update products with same id

    Then, I go to my webshop and click on “Wine”. On the category archive page, I can see “Other wines (515)”, but when I click to watch this subcategory, there is nothing to display until I edit thoses products with WP.

    This make me suppose that the problem is not related to my API query (everything looks fine). Maybe it is because I cannot set one category as the Main one… What do you think ? I noticed the “Main” category is related to Yoast seo plugin.

    I’m getting this problem as well when trying to set products to ANY categories via the REST API. If I go to the WP product editor, the product shows the categories exactly as I set them with the API but does not show up on the category page or in the shop page when filtering by category. If I just hit the update button (I don’t actually change anything at all) from the WP product editor, it then shows up as expected under the category pages and when filtering.

    Couple things I noticed:
    – The response when updating via REST API and the response from a GET request after manually hitting the update button in WP product editor are exactly the same except that the GET response lists the ID of the other products in that category under “related_ids”: [] and put a <p>…</p>\n around the “short_description”:””
    – The product count is only increased by 1 in the specific categories that were set via the REST API. Any parent category counts are not increased by 1 until I manually hit the update button in the WP product editor. I’ve tried making the REST API set the product to any parent categories of the desired subcategory but that doesn’t work.

    This leads me to believe that updating a product via the REST API isn’t triggering woocommerce to regenerate the product and update any counts as it should and does when you hit the update button in the WP product editor.

    As for how to fix it, I have no idea yet… I’ve wasted 2 days trying to get this to work thinking it’s an issue with my API request. It is not. Guess it’s time to start digging through the core files but would love an idea about where to start, like if there is a hook or function called normally to process the regeneration.

    This is not resolved. It is happening exactly the way as described in my customer’s shop as well.

    Did anyone find any solution by now? I have the exact same problem in my customers shop.

    Same problem here.
    Is there a way to update the product as when we hit the button to update prooduct?

    Mirko P.

    (@rainfallnixfig)

    Hey @adminbuzina,

    Thanks for reaching out on the forum.

    Since this thread is closed you’d want to open your own thread and we’ll check from there.

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Products created with REST API don’t display in subcategory archive’ is closed to new replies.