Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Replacement for addExpressionAttributeToSelect in sales/order_collection version 1.4.1.0
 
MageTitan
Member
 
Avatar
Total Posts:  58
Joined:  2009-10-16
Salt Lake City, Utah USA
 

I used to use addExpressionAttribute to pull a custom order report and send the email. The report includes count of sales, total sales amount, so I would do something like this:

$_collection Mage::getResourceModel('sales/order_collection')
        ->
addExpressionAttributeToSelect('total_sales''SUM({{grand_total}})''grand_total')
        ->
addExpressionAttributeToSelect('order_count''COUNT({{grand_total}})''grand_total');
Is there a replacement way of adding custom expressions to the select statement now for the flat sales table?

(Sorry for the double post...)

 
Magento Community Magento Community
Magento Community
Magento Community
 
nlmedia
Jr. Member
 
Total Posts:  12
Joined:  2009-02-16
 

We are having a similar problem. Is that method gone? Is there docs on changes to the SOAP API for orders in 1.4?

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect()

Help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Did you try:

$_collection Mage::getResourceModel('sales/order_collection');
$_collection->getSelect()
        ->
from(null, array('total_sales' => 'SUM(grand_total)'))
        ->
from(null, array('order_count' => 'COUNT(grand_total)'));

DISCLAIMER:  I haven’t tested the above code, but it’s how the addExpressionAttributeToSelect() method worked.

EDIT: Fixed minor typo/bug (and another one)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Coady
Member
 
Total Posts:  41
Joined:  2010-02-13
 

Looking at Sales > Orders in 1.4.1.0 I see this error:

Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/insider/diurnetix.com/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php on line 57

The system is taking orders but failing to notify anyone :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
tokalpeshdp
Member
 
Total Posts:  69
Joined:  2010-07-27
 

After upgrade from version 1.4.0.1 to version 1.4.1.0 through Magento Connect, I have this error:

Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/nexusgrp/public_html/drugstoreshopping.com/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php on line 57

oh oh

Has any body find a solution for this error?

Thinkcyber

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Coady
Member
 
Total Posts:  41
Joined:  2010-02-13
 
bugmen0t! - 10 August 2010 04:07 AM

After upgrade from version 1.4.0.1 to version 1.4.1.0 through Magento Connect, I have this error:

Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/nexusgrp/public_html/drugstoreshopping.com/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php on line 57
Thinkcyber

Have you tried applying the 1.4.1.1 patch?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tokalpeshdp
Member
 
Total Posts:  69
Joined:  2010-07-27
 

thanks for the reply. Unfortunately this patch does not resolve the problem.
Also under Customers -> Manage Customers -> recent orders, I have this similar error:
Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/public_html/mydomain.com/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php on line 67

Any other idea or hint?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Coady
Member
 
Total Posts:  41
Joined:  2010-02-13
 
bugmen0t! - 10 August 2010 09:09 AM

thanks for the reply. Unfortunately this patch does not resolve the problem.
Also under Customers -> Manage Customers -> recent orders, I have this similar error:
Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/public_html/mydomain.com/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View/Orders.php on line 67

That’s one of the bugs that patch was designed to fix. I don’t know if you applied it properly and suspect that the instructions for applying it maybe a little misleading.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tokalpeshdp
Member
 
Total Posts:  69
Joined:  2010-07-27
 

Hi Tom,

I used this patch: http://www.magentocommerce.com/blog/comments/magento-ce-version-1411-stable-patch/

How did I do it: I compared the files from the patch with the files I have on the server and they have the exact same file size.
What is the correct way to apply this patch?

Also I want to mentioned, I updated through “Magento Connect” on Aug. 7th. I updated also the modern theme.
Where can I find the correct instructions to apply this patch?

Thanks for your help, I appreciate it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rhaps
Jr. Member
 
Total Posts:  29
Joined:  2007-11-24
 

Bugmen0t, same problem than me, still looking for a patch or workaround.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Coady
Member
 
Total Posts:  41
Joined:  2010-02-13
 

Just to say I’ve had a quick look for upgrade instructions and failed but note there is a new beta which you might try assuming its easy enough for you to roll back.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tokalpeshdp
Member
 
Total Posts:  69
Joined:  2010-07-27
 

As for me this is not an option, as well the Magento version 1.4.2.0-beta1, just Included new Magento Connect Manager 2 and it was made 1 day after the release of 1.4.1.1

Does any body know what happened to Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() function?
still searching…

 
Magento Community Magento Community
Magento Community
Magento Community
 
tokalpeshdp
Member
 
Total Posts:  69
Joined:  2010-07-27
 
Tom Coady - 10 August 2010 06:00 AM

bugmen0t! - 10 August 2010 04:07 AM
After upgrade from version 1.4.0.1 to version 1.4.1.0 through Magento Connect, I have this error:

Fatal error: Call to undefined method Mage_Sales_Model_Mysql4_Order_Collection::addExpressionAttributeToSelect() in /home/myfolder/public_html/mydomain.com/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php on line 57
Thinkcyber

Have you tried applying the 1.4.1.1 patch?

For me the patch did not work. This worked:
copy ./fresh_magento_1_4_1_1/app/code/core/Mage/ over ./<already_updated_magento_1_4_1_1>/app/code/core/Mage/

Solved my issue.

Thinkcyber

 
Magento Community Magento Community
Magento Community
Magento Community
 
joshuajarman
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2009-04-08
 

I have this issue with a clean install of 1.4.2, did anybody ever find a solution?  thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top