1

join query with customer table getSize() count mismatch with the mysql db result.

Query
-----
$collection = Mage::getModel('customer/customer')->getCollection();
$collection->getSelect()->join(array('endorsement'=>'flendorsement'),'e.entity_id = endorsement.to_user_id',array('total_endorsement'=>'COUNT(endorsement.endorsement_id)'));
            $collection->getSelect()->group('endorsement.to_user_id');

When i execute this query in mysql phpmyadmin, there will show the 3rows,
but  getSize() method return "2"

see the screen below:

enter image description here

4

Use this

$collection->count();

For getSize() the collection is not loaded. For count() it is.

Check the difference between getSize() and count() from here Difference between getSize() and count() on collection

  • the getCount() is used in custom table collection, but here i wrote the query with Magento table, that's why i am using getSize(),then i have a pagination issues also with the group by query, for your further reference i attached the screen. – senthil Jul 14 '15 at 6:47
  • getSize() does not load the collection for records that come from the data base. you need to override the method and tell it to load the collection – Manashvi Birla Jul 14 '15 at 6:54
  • How can i override the getSize(),can you explain that or having any tutorial for getSize() override? – senthil Jul 14 '15 at 7:01
  • TRy this ka.lpe.sh/2012/01/05/… it might help you – Manashvi Birla Jul 14 '15 at 7:05
  • thanks for your support,now its working. then i have one more problem, i posted the question see the link magento.stackexchange.com/questions/74278/… – senthil Jul 14 '15 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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