简体   繁体   中英

Woocommerce API rest client retrieve products

I'm using a Woocommerce REST client API to get products from a Wordpress website. However, when I execute this command:

this->client->products->get();

to get all products, I only have 10 products returned. What might be the problem?

I solved it. Nothing to do with the rest client itself. It is wordpress configuration. Just got to settings -> Reading -> and change "Blog pages show at most" or "Syndication feeds show the most recent" to (50) or as you like

Hope it is helping .

Setting Blog pages show at most property is not the solution to this problem. By doing that you're changing behaviour of other pages on your site too. Use following code instead:

$this->client->products->get(null, array('filter[limit]' => -1));

use -1 to get all the products or just use any number to limit it upto that number.

To retrieve all the products use the limit filter,

To get the 50 products ---- filter[limit]=50

To get all the products --- filter[limit]=-1

http://example.com/wc-api/v3/products?filter[limit]=50&oauth_consumer_key=ck_050f0a06050e2789b2c61d6bd66d2c97d3780580&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1448179257&oauth_nonce=Ac52xk&oauth_version=1.0&oauth_signature=eBm5/3CP6kw1K8F033wHnVpAKiw=

No need to change the code etc. only use the limit filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM