Search code examples
magentomagento-1.5

Magento:: How to filter the excess information?


i'm trying to get the customer list through an api call & i'm getting the list of customer's details but its returning all the attributes associated with the customers, but i want only customer name,employee_id,email to be retrieved. in the magento api wiki i found that customer.list accepts two sets of arguments(array filters & filter list) could someone tell me the difference b/w the two arguments i tried using the code below to retrive only customer_id,email & firstname but var_dump(); displays all the customer info how do i retrieve only the attribute's that i want? Thanks in advance.

<?php 
     $proxy = new SoapClient('http://www.localhost/magento/index.php/api/soap/?wsdl');
    $sessionId = $proxy->login('test', '123456');
    // Get new customer info
    $filters=array('employee_id'=>array('eq'=>'234567'));
    $filter_list=array('customer_id','email','firstname');
    $results= $proxy->call($sessionId, 'customer.list',array($filters),array($filter_list));
    var_dump($results);  

    ?>

Solution

  • Filters are for retrieving only the customer records that match those specific attributes.

    You have several options:

    1. Add a new API endpoint to retrieve the values you want.
    2. Hack the core Customer wsdl and remove the unwanted attributes.
    3. After your API call go through each array and unset the unwanted values.

    Adding a custom endpoint

    Well basically you have to create a new module that extends the core api its not hard to do the following guide covers it on detail

    http://www.magentocommerce.com/wiki/doc/webservices-api/custom-api