4

I am trying to retrieve all customers from my magento shop, but only those who activated the newsletter subscription in their account.

Problem: I cant figure out how to filter this attribute ("newsletter", is there one?).

I got:

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$params = array(
    'sessionId' => $session_id,
    'filters' => null
);
$allCustomers = $proxy->customerCustomerList($params);

This returns ALL customers. Any ideas how to filter this by newsletter-subscription?

sladda
  • 332
  • 5
  • 12

1 Answers1

4

Newsletter subscriptions are stored is a separate module. Mage_Newsletter. There doesn't appear to be any API coverage for this module, however if you take a quick peak at the newsletter_subscriber database table you'll see subscribers that are also customers have a foreign key relating them.

I'd probably look at adding an attribute to Mage_Customer that holds subscription status, adding an observer to the subscribe and unsubscribe events to update it.

I'd then look to add this attribute to the Mage_Customer API so I can filter by it when grabbing the customers.

Observers on subscription events: https://stackoverflow.com/a/12991195/2205881 and Adding a custom field to Magento's subscription module

Extending the v2 API: http://inchoo.net/ecommerce/magento/magento-api-v2/

Community
  • 1
  • 1
rjocoleman
  • 346
  • 1
  • 6