-
-
Save paulchubatyy/998558 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$result = Mage::getModel('customer/customer')->getCollection() | |
->join(array('pet' => $this->getTable('partners_earn_transactions')), $this->getTable('customer_entity').'.entity_id = `pet`.customer_id') // Этот метод точно есть в Collection классе? Может нужно взять getCollection()->getSelect() перед тем как колать join? | |
->addExpressionFieldToSelect('transaction_count', 'COUNT({{pet.id}})') | |
->addAttributeToFilter('country_id', $country_code) | |
->addFieldToFilter('is_active', 1) | |
->addAttributeToSort('COUNT({{pet.id}})') | |
->addAttributeToSort('SUM({{pet.points}})') | |
->groupByAttribute($this->getTable('customer_entity').'.entity_id') | |
->limit(5) | |
->load(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment