2016-07-07 8 views
0

私のMagentoストアには32の製品があります。私はMagento Rest API製品リスト(api/rest/products)最後のページまたは製品を知る方法

http://localhost/magento/api/rest/products?page=1&limit=10 
http://localhost/magento/api/rest/products?page=2&limit=10 
http://localhost/magento/api/rest/products?page=3&limit=10 
http://localhost/magento/api/rest/products?page=4&limit=10 

以下のように、Magentoの残りのAPIを使用して、これらの製品を取得していますが、私はあまりにも、URLの下に照会すると、まだそれは、製品のリストを与えている

(ページが5に等しいではないしてください)

http://localhost/magento/api/rest/products?page=5&limit=10 

これは、これが最後のページか最後の製品であることを知る方法はありますか?

答えて

0
  ProductWork mojProduct = new ProductWork(_url, _adminUrlPart, _consumerKey, 
         _consumerSecret, _userName, _password); 


      MagentoApiResponse<IList<Product>> provera = new MagentoApiResponse<IList<Product>>(); 
      provera.Result = new List<Product>(); 
      for (int i = 0; i < 100; i++) 
      { 

       var filter = new Filter(); 
       filter.PageSize = 100; // max number 
       filter.Page = i+1; 
       var primio = await mojProduct.GetAll(filter); 

        if (primio.Result != null & provera != null) 
        { 
         foreach (Product item in primio.Result) 
         { 
          if (provera.Result.Count(a=>a.entity_id == item.entity_id) == 0) { 
           provera.Result.Add(item); 
          } 
          else 
          { 
           i = 101; 
           break; 
          } 

         } 
        } 
        else 
        { 

         break; 
        } 

       } 



      if (provera.Result != null) 
      { 
       foreach (Product item in provera.Result) 
       { 
        // your code here 

       } 

      } 
+0

答えも説明してください。 –

関連する問題