Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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

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

share|improve this answer
add comment

Try to use just email instead of main_table.email.

share|improve this answer
    
In UPDATE case main table is not newsletter_subscriber –  sergio Mar 12 at 13:55
    
Yes, you are right. Please see my updated answer. –  Tim Mar 12 at 14:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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