<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting Customer&#039;s Info Using Single Query Including Billing and Shipping Addresses</title>
	<atom:link href="http://subesh.com.np/2010/01/customers-info-single-query-including-billing-shipping-addresses/feed/" rel="self" type="application/rss+xml" />
	<link>http://subesh.com.np/2010/01/customers-info-single-query-including-billing-shipping-addresses/</link>
	<description>PHP &#38; Magento Tips and Tutorials</description>
	<lastBuildDate>Fri, 27 Jan 2012 10:29:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Subesh Pokhrel</title>
		<link>http://subesh.com.np/2010/01/customers-info-single-query-including-billing-shipping-addresses/#comment-304</link>
		<dc:creator>Subesh Pokhrel</dc:creator>
		<pubDate>Tue, 19 Jan 2010 08:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://subesh.com.np/?p=184#comment-304</guid>
		<description>I guess you have already added product_presale as product&#039;s attribute, I tried registering one such attribute with code &quot;product_presale&quot; and added its id in the query (second part) and the query ran well in phpmyadmin as well as it sent me collection values. The column retured, should be retreived using

foreach($collection as $coll){
	print_r($coll-&gt;getPresaleItemCount());
}

As you can see in PHPMyadmin result column added presale_item_count. I think you did the hardest part and missed at last..or I didn&#039;t understand what you want :D</description>
		<content:encoded><![CDATA[<p>I guess you have already added product_presale as product&#8217;s attribute, I tried registering one such attribute with code &#8220;product_presale&#8221; and added its id in the query (second part) and the query ran well in phpmyadmin as well as it sent me collection values. The column retured, should be retreived using</p>
<p>foreach($collection as $coll){<br />
	print_r($coll->getPresaleItemCount());<br />
}</p>
<p>As you can see in PHPMyadmin result column added presale_item_count. I think you did the hardest part and missed at last..or I didn&#8217;t understand what you want <img src='http://subesh.com.np/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sajid</title>
		<link>http://subesh.com.np/2010/01/customers-info-single-query-including-billing-shipping-addresses/#comment-303</link>
		<dc:creator>sajid</dc:creator>
		<pubDate>Mon, 18 Jan 2010 12:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://subesh.com.np/?p=184#comment-303</guid>
		<description>Thanks for great notes ,

I have some issue you might could help ,
    $collection = Mage::getResourceModel(&#039;sales/order_collection&#039;)
            -&gt;addAttributeToSelect(&#039;*&#039;)
            -&gt;joinAttribute(&#039;billing_firstname&#039;, &#039;order_address/firstname&#039;, &#039;billing_address_id&#039;, null, &#039;left&#039;)
            -&gt;joinAttribute(&#039;billing_lastname&#039;, &#039;order_address/lastname&#039;, &#039;billing_address_id&#039;, null, &#039;left&#039;)
            -&gt;joinAttribute(&#039;shipping_firstname&#039;, &#039;order_address/firstname&#039;, &#039;shipping_address_id&#039;, null, &#039;left&#039;)
            -&gt;joinAttribute(&#039;shipping_lastname&#039;, &#039;order_address/lastname&#039;, &#039;shipping_address_id&#039;, null, &#039;left&#039;)
            -&gt;addExpressionAttributeToSelect(&#039;billing_name&#039;,
                &#039;CONCAT({{billing_firstname}}, &quot; &quot;, {{billing_lastname}})&#039;,
                array(&#039;billing_firstname&#039;, &#039;billing_lastname&#039;))
            -&gt;addExpressionAttributeToSelect(&#039;shipping_name&#039;,
                &#039;CONCAT({{shipping_firstname}}, &quot; &quot;, {{shipping_lastname}})&#039;,
                array(&#039;shipping_firstname&#039;, &#039;shipping_lastname&#039;))
            -&gt;joinAttribute(&#039;shipping_country_id&#039;, &#039;order_address/country_id&#039;, &#039;shipping_address_id&#039;, null, &#039;left&#039;)
            -&gt;addExpressionAttributeToSelect(&#039;international&#039;,
                &#039;(&quot;US&quot; = {{shipping_country_id}})&#039;,
            array(&#039;shipping_country_id&#039;))

            -&gt;joinField(&#039;item_product_id&#039;, &#039;sales/order_item&#039;, &#039;product_id&#039;, &#039;order_id=entity_id&#039;, null, &#039;left&#039;)
            -&gt;groupByAttribute(&#039;entity_id&#039;);

        // Add the presale column
        $collection-&gt;getSelect()-&gt;joinLeft(
                array(&#039;product_presale&#039;=&gt;&#039;catalog_product_entity_int&#039;),
                &#039;product_presale.entity_id=`_table_item_product_id`.`product_id` and product_presale.attribute_id=&#039;.$productattribute-&gt;getAttributeId(),
                array(&#039;presale_item_count&#039;=&gt;new Zend_Db_Expr(&#039;SUM(product_presale.value)&#039;))
            );

When I m applying having method on presale.value its giving me error of sqlstate unknown column where its query work fine on phpmyadmin

could u help me in this

sajid</description>
		<content:encoded><![CDATA[<p>Thanks for great notes ,</p>
<p>I have some issue you might could help ,<br />
    $collection = Mage::getResourceModel(&#8216;sales/order_collection&#8217;)<br />
            -&gt;addAttributeToSelect(&#8216;*&#8217;)<br />
            -&gt;joinAttribute(&#8216;billing_firstname&#8217;, &#8216;order_address/firstname&#8217;, &#8216;billing_address_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;joinAttribute(&#8216;billing_lastname&#8217;, &#8216;order_address/lastname&#8217;, &#8216;billing_address_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;joinAttribute(&#8216;shipping_firstname&#8217;, &#8216;order_address/firstname&#8217;, &#8216;shipping_address_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;joinAttribute(&#8216;shipping_lastname&#8217;, &#8216;order_address/lastname&#8217;, &#8216;shipping_address_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;addExpressionAttributeToSelect(&#8216;billing_name&#8217;,<br />
                &#8216;CONCAT({{billing_firstname}}, &#8221; &#8220;, {{billing_lastname}})&#8217;,<br />
                array(&#8216;billing_firstname&#8217;, &#8216;billing_lastname&#8217;))<br />
            -&gt;addExpressionAttributeToSelect(&#8216;shipping_name&#8217;,<br />
                &#8216;CONCAT({{shipping_firstname}}, &#8221; &#8220;, {{shipping_lastname}})&#8217;,<br />
                array(&#8216;shipping_firstname&#8217;, &#8216;shipping_lastname&#8217;))<br />
            -&gt;joinAttribute(&#8216;shipping_country_id&#8217;, &#8216;order_address/country_id&#8217;, &#8216;shipping_address_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;addExpressionAttributeToSelect(&#8216;international&#8217;,<br />
                &#8216;(&#8220;US&#8221; = {{shipping_country_id}})&#8217;,<br />
            array(&#8216;shipping_country_id&#8217;))</p>
<p>            -&gt;joinField(&#8216;item_product_id&#8217;, &#8216;sales/order_item&#8217;, &#8216;product_id&#8217;, &#8216;order_id=entity_id&#8217;, null, &#8216;left&#8217;)<br />
            -&gt;groupByAttribute(&#8216;entity_id&#8217;);</p>
<p>        // Add the presale column<br />
        $collection-&gt;getSelect()-&gt;joinLeft(<br />
                array(&#8216;product_presale&#8217;=&gt;&#8217;catalog_product_entity_int&#8217;),<br />
                &#8216;product_presale.entity_id=`_table_item_product_id`.`product_id` and product_presale.attribute_id=&#8217;.$productattribute-&gt;getAttributeId(),<br />
                array(&#8216;presale_item_count&#8217;=&gt;new Zend_Db_Expr(&#8216;SUM(product_presale.value)&#8217;))<br />
            );</p>
<p>When I m applying having method on presale.value its giving me error of sqlstate unknown column where its query work fine on phpmyadmin</p>
<p>could u help me in this</p>
<p>sajid</p>
]]></content:encoded>
	</item>
</channel>
</rss>

