• Resolved reeko6616

    (@reeko6616)


    I have this code that basically fetches images from our wholesale site and is meant to upload them to our retail site as both sites use the same categories however I noticed the API is not adding images to the categories and I do not know why, hoping someone can shed some light, sorry about the mess, quick an dirty

    from woocommerce import API
    import json
    
    wholesale = API(
        url="",
        consumer_key="",
        consumer_secret="",
        wp_api=True,
        version="wc/v3"
    )
    
    retail = API(
        url="",
        consumer_key="",
        consumer_secret="",
        wp_api=True,
        version="wc/v3"
    )
    
    page = 1
    while True:
        categoryData = wholesale.get("products/categories", params={'per_page': 100, 'page': page}).json()
        if len(categoryData) == 0: 
            break
        for item in categoryData:
            try:
                retailcat = retail.get("products/categories/", params={'name': item['name'], 'slug': item['slug']}).json()
                data = {"images": [{"src": "\"" + item['image'].get('src') + "\""}]}
                for item2 in retailcat:
                    retail.put("products/categories/"+str(item2['id']), data).json() 
            except:
                print(item['name'], item['slug'])
        page = page + 1
    • This topic was modified 4 years ago by reeko6616.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ross V. a11n

    (@rossviviano)

    Automattic Happiness Engineer

    Hi there,

    This is a fairly complex development topic, so I’m going to leave it open for a bit to see if anyone is able to jump in to help you out.

    I can also recommend the following places for more development-oriented questions:

    WooCommerce Slack Community: https://woocommerce.com/community-slack/
    Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Best,

    Ross

    Plugin Support Ross V. a11n

    (@rossviviano)

    Automattic Happiness Engineer

    Hi again,

    It doesn’t look like anyone is able to hop in and help out, so your best bet is to get in touch with one of the groups mentioned in my previous post.

    Best,

    Ross

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woo API Category Images not uploading’ is closed to new replies.