2

I would like to know how to retrieve products that belong to a specific category in Magento SOAP API V2, with WS-I compliance and also without.

Here's what I've tried in WS-I compliance mode:

$proxy = new SoapClient('http://foobar.local/api/v2_soap/?wsdl');

$sessionId = $proxy->login(array(
    'username' => 'foo',
    'apiKey' => 'bar'
));

$filters = array( 'complex_filter' =>
    array(
        array(
            'key' => 'category_ids',
            'value' => array( 'key' => 'like', 'value' => '%1%' )
        )
    )
);

$result = $proxy->catalogProductList(array('sessionId' => $sessionId->result, 'filters' => $filters));

var_dump($result->result);

I can use the complex filter to successfully filter by product_id however this fails to work for category_ids as it has another nested level. How can I retrieve products via the Magento API for a certain category ID? Should I be using catalog_category.assignedProducts?

  • 4
    I'm voting to close this question as off-topic due to inactivity from the OP. – Anna Völkl Feb 18 '15 at 10:59
  • Are you kidding me? Not a specific coding question about the Magento e-Commerce platform? – Francis Kim Feb 18 '15 at 23:10
  • 2
    People vote blindly in efforts to rack up points. I've raised this but haven't gotten much of a response. Voting to re-open. – SR_Magento Feb 19 '15 at 0:26
  • I would like to hear from the users including @AnnaVölkl that flagged this question, on how my question "does not appear to be about the Magento e-Commerce platform" and how it does not fit within the scope defined. – Francis Kim Feb 19 '15 at 1:31
  • 1
    @FrancisKim there is a limited inventory of reasons why questions can be put on hold. As Anna stated your question is on hold because it appears you failed to follow up on the first comment on Dec 9. However, I think what was missed was your follow-up edit on Dec 10 which I think addresses the comment. Reopening. – benmarks Feb 19 '15 at 4:25
3

As you already noted in your question, the preferred way of retrieving products which belong to a specific category is catalogCategoryAssignedProducts for SOAPv2 (see documentation here).

catalogProductList is a way of retrieving products by attributes.

Please note that catalogCategoryAssignedProducts fetches only products from one specific category and not multiple ones.

The SOAP calls according to documentation are:

SOAPv2:

$result = $proxy->catalogCategoryAssignedProducts($sessionId, '4');

SOAPv2 WS-I:

$result = $proxy->catalogCategoryAssignedProducts((object)array('sessionId' => $sessionId->result, 'categoryId' => '4'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.