0
votes

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?

3
It sounds like you need to provide a numberposts or posts_per_page parameter with your request. - rnevius
how i could do that ? - Eman Ibrahim Mohammed

3 Answers

1
votes

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 .

1
votes

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.

0
votes

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.