2013-01-21 77 views

回答

5
+0

雖然是正確的,但它僅限於你不得不分數達到50或更少,並且你不能在網站的其他任何地方拉超過50。 –

+1

您可以一次拉取250個API,並將分頁設置爲1000,例如,前端代碼可以拉1000.除非您爲自己設置或不做任何操作,否則沒有50的限制。 –

+0

「不要將集合分頁超過50個,這是您應該每頁查詢的最大數量的產品。」根據他們自己的文檔在這裏看到:http://docs.shopify.com/themes/liquid-variables/paginate –

0

獲取所有產品一次或運行在shopify本店所有商品查詢(API請求): 使用這個程序是更管理 - >https://github.com/phpish/shopify_private_app-skeleton所以,我的解決方案下面是基於這個應用程序,或者你可以與你的解決方案的解決方案,以及

<?php 

session_start(); 

require __DIR__.'/vendor/autoload.php'; 
use phpish\shopify; 
require __DIR__.'/conf.php'; 

$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true); 

try 
{ 
    $products = $shopify('GET /admin/products/count.json', array('published_status'=>'published')); 

    $totalproducts = $shopify('GET /admin/products/count.json', array('published_status'=>'published')); 
    $limit = 50; 
    $totalpage = ceil($totalproducts/$limit); 
    for($i=1; $i<=$totalpage; $i++){ 
     $products = $shopify('GET /admin/products.json?'.$limit.'=50&page='.$i, array('published_status'=>'published')); 
     foreach($products as $product){ 
      //do anything at once for all the products in store 
     } 
    } 
    } 
    catch (shopify\ApiException $e) 
    { 
    // 
    } 

總結:我們的想法是檢索與頁面= x作爲對儀表。在計算出頁數後,我們將以指定的限制,即50次一次獲取。