What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Fetch orders and variants is slow

Fetch orders and variants is slow

kahmra
Tourist
9 0 2

Hi there! I try to fetch the orders and for each order I go featch each variant to extract its details, but this is very slow, is there any way to improve the speed of this?

here is my code

$orders=json_shopify("https://'.$user.':'.$password.'@'.$shop_domain.'/admin/api/2021-07/orders.json?limit=250&status=open&financial_status=paid");
foreach ($orders['orders'] as $order) {
foreach ($order['line_items'] as $item){
$variant =https://'.$user.':'.$password.'@'.$shop_domain.'/admin/api/2021-07/variants/'.$variant_id.'.json
Reply 1 (1)

Bunty
Shopify Partner
133 39 82

You are processing sequentially, you can change the code to parallel process with rate limiting checks (to cool down the thread when close to the limits). That is substantially faster than what you have below.