2

So, I have subscribers collection:

$subscribersCollection =  Mage::getModel('newsletter/subscriber')->getCollection();

I want to join customer collection to it by email, so I did next:

$subscribersCollection->getSelect()
     ->join(array('cus'=>'customer_entity'),'cus.email=main_table.subscriber_email');

But in this way I only join customer_entity table, but not all the customer collection. I think about also join other customers tables. Is there any better way to join customer collection?

UPDATE:

I have tried

$customerCollection = Mage::getResourceModel('customer/customer_collection'); 
$customerCollection->getSelect()->join(array('cus'=>'newsletter_subscriber'),'cu‌​s.subscriber_email = e.email');
$customerCollection->getItems()

Now it work, thanks

0

2 Answers 2

4

You're going to kick yourself when I show you :-)

Create a customer collection instance and join the newsletter table on that.

0
1

Try to use just email instead of main_table.email.

2
  • In UPDATE case main table is not newsletter_subscriber
    – sergio
    Commented Mar 12, 2014 at 13:55
  • Yes, you are right. Please see my updated answer. Commented Mar 12, 2014 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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