2010-04-29 11 views
2

내 스토어 용 웹 서비스를 만들고 있습니다. Magento API를 사용하여 상점에서 제품 목록을 수집하고 있습니다. 하지만 500 개의 모든 레코드가 표시됩니다. 페이지 당 25 개의 레코드가 필요합니다. API 호출에 추가 할 내용은 무엇입니까? 또는 어떤 필터가 적용됩니까?Magento API 호출에서 한도 옵션을 추가하는 방법

// soap 객체를 생성하십시오. $ proxy = new SoapClient ('http://localhsot/magento/api/soap/?wsdl');

// create authorized session id using api user name and api key 
// $sessionId = $proxy->login('apiUser', 'apiKey'); 
$sessionId = $proxy->login('test_admin', '12345678'); 

    $filters = array(


    ); 


// Get list of product 
$productlist = $proxy->call($sessionId, 'product.list', array($filters)); 

print_r($productlist); 

답변

-1

할 수있는,이 확실하지 오전하지만 API는 컬렉션과 협력 당신이 시도 할 수이 작동하지 않았다 모음 크기

$filters = array(
    'setPageSize' => 10 
); 
0

을 제한 할 수있는 방법입니다

$filters = array('id'=>array("gteq"=>1), 'id'=>array("lteq"=>1000)); 

일부 페이징을 추가 할 수있는 방법 : 당신은 같은 ID로 그것을 제한?

0

나는 이것이 오래된 질문이라는 것을 알고 있지만 나는 이것으로 어려움을 겪었다. 필자는 기본 catalogProductList 함수와 정확히 동일하지만 추가 매개 변수를 가진 자체 SOAP API 끝점을 만들었습니다. 아래의 코드를 참조하십시오 :

$collection = Mage::getModel('catalog/product')->getCollection() 
    ->addStoreFilter($this->_getStoreId($store)) 
    ->addAttributeToSelect('name'); 
if($limit) { 
    $collection->setOrder('updated_at', 'ASC'); 
    $collection->setPageSize($limit); 
} 
/** @var $apiHelper Mage_Api_Helper_Data */ 
$apiHelper = Mage::helper('api'); 
$filters = $apiHelper->parseFilters($filters, $this->_filtersMap); 
try { 
    foreach ($filters as $field => $value) { 
     $collection->addFieldToFilter($field, $value); 
    } 
} catch (Mage_Core_Exception $e) { 
    $this->_fault('filters_invalid', $e->getMessage()); 
} 
$result = array(); 
foreach ($collection as $product) { 
    $result[] = array(
     'product_id' => $product->getId(), 
     'sku'  => $product->getSku(), 
     'name'  => $product->getName(), 
     'set'  => $product->getAttributeSetId(), 
     'type'  => $product->getTypeId(), 
     'category_ids' => $product->getCategoryIds(), 
     'website_ids' => $product->getWebsiteIds(), 
     'updated_at' => $product->getUpdatedAt(), 
     'created_at' => $product->getCreatedAt() 
    ); 
} 
return $result; 

을 그리고 거기에서 우리는 마지막 updated_at 값을 추적하고 필터로 다음 [LIMIT] 항목을 얻을 것을 사용합니다. 기본적으로 updated_at 및 created_at은 응답에 없으며 updated_at에 의해 목록이 정렬되지 않으므로 추가했습니다.

관련 문제