Skip to main content
15 events
when toggle format what by license comment
Jul 9, 2015 at 3:42 vote accept HungDQ
Jul 3, 2015 at 8:20 comment added HungDQ I really appreciate your help. I'm looking for your answer. Nice explanation!
Jul 3, 2015 at 8:14 comment added Fabian Schmengler OK, I think I understand the problem: addExpressionAttributeToSelect only works with expressions based on actual EAV attributes, not joined tables, while addExpressionFieldToSelect is not available. You should use joinTable and specify the expression as Zend_Db_Expr. I will update the answer later with more information when I find the time
Jul 3, 2015 at 8:09 comment added HungDQ I've tried but still got same error. It seems that problem was in this line: $collection->addExpressionAttributeToSelect("page_view", "sum({{page_view}})", "page_view");
Jul 3, 2015 at 8:05 history edited Fabian Schmengler CC BY-SA 3.0
Fixed group statement
Jul 3, 2015 at 8:03 comment added Fabian Schmengler I made a stupid mistake. Of course you don't want to group by page_view, but to group by the customer id $collection->getSelect()->group("main_table.entity_id")
Jul 3, 2015 at 8:00 comment added HungDQ I've just updated my code to my question. Could you take a look please ?. I cannot thank you enough.
Jul 3, 2015 at 7:52 comment added Fabian Schmengler it cannot be the same error with the method name addExpressionAttributeToSelect
Jul 3, 2015 at 7:42 comment added HungDQ I've tried to use the second way but got this error: Call to a member function getBackend() on a non-object in E:\XAMPP\htdocs\stat\app\code\core\Mage\Eav\Model\Entity\Collection\Abstract.php on line 513.
Jul 3, 2015 at 7:38 comment added Fabian Schmengler OK for EAV collections like the customer collection it works a bit different. See updated answer
Jul 3, 2015 at 7:38 history edited Fabian Schmengler CC BY-SA 3.0
EAV solution
Jul 3, 2015 at 7:33 comment added HungDQ Not sure why I got this error: Call to undefined method Mage_Customer_Model_Resource_Customer_Collection::addExpressionFieldToSelect(). My collection is: $collection = Mage::getResourceModel('customer/customer_collection'). I'm using magento 1.6.1.0
Jul 3, 2015 at 7:30 history edited Fabian Schmengler CC BY-SA 3.0
added 163 characters in body
Jul 3, 2015 at 7:28 comment added Amit Bera Good answer.. I just typing answer.. But you give first +V1
Jul 3, 2015 at 7:24 history answered Fabian Schmengler CC BY-SA 3.0