• Resolved sgp57

    (@sgp57)


    I’m trying to use wc-cli to add products. I cannot get wp wc product create --images to work. The command will create a product but will be there without the image.

    Using the GUI, I am able to create a product with an image and also to update/change the product image. I can also see that data in the database and view that data using wp listing commands.

    I am able to use wp media import to upload an image and get the image id. I am also able to get the image url using

    wp post get $imageId --field='guid'

    The only way that I have succeeded in creating a product with an image so far is to write a CSV file and import the product however wc-cli does not support product import and does not have sufficient interest to add that capability.

    I assume my problem is how to use the --images argument?

    It would be good to know how to use --images with a url, a file name and an existing (media) image id. Explanation of argument format, guidance and examples will be appreciated please! (Especially the examples…)

    • This topic was modified 3 years, 9 months ago by sgp57.
Viewing 2 replies - 1 through 2 (of 2 total)
  • dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @sgp57

    I haven’t used this myself but I looked at the Wiki for WC CLI – https://github.com/woocommerce/woocommerce/wiki/WC-CLI-Overview#frequently-asked-questions

    Using the last question, it looks like you need to format the command in a specific way:

    wp wc product create --name='Product Name' --categories='[ { "id" : 21 } ]' --user=admin

    Can you let me know what happens if you use --images= and then the id of the image to use?

    Thanks,

    Thread Starter sgp57

    (@sgp57)

    Many thanks @dougaitken!!!

    I think my underlying problem(s) were the details of specifying the object and from a script – I thought that I had tried what you suggest, but clearly not.

    Yes, it does work for --image.

    A basic example that worked for me was

    wp wc product create --images='[{"id":46}]' --user=1

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp wc-cli – adding product image’ is closed to new replies.