Eman Ibrahim Mohammed
Eman Ibrahim Mohammed

Reputation: 31

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?

Upvotes: 0

Views: 4748

Answers (3)

Wasim Khan
Wasim Khan

Reputation: 1237

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.

Upvotes: 0

Akash K.
Akash K.

Reputation: 637

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.

Upvotes: 1

Eman Ibrahim Mohammed
Eman Ibrahim Mohammed

Reputation: 31

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 .

Upvotes: 1

Related Questions