Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After looking under the hood I learned that <code>_selectAttributes</code> instance field was not assigned in <code>Mage_Eav_Model_Entity_Collection_Abstract</code> class and that is why get exception. A solution usually would be what Jonathan Day suggested above - add <code>addAttributeToFilter()</code> method, however. It will return error since it cannot find such attribute for catalog/product. (<code>qty</code> and <code>in_invetory</code> are in <code>cataloginventory_stock_item</code>). I found two solutions to my problem both required going different direction:</p> <ol> <li><p>One involved pursuing a way to query the Select statement that I had set for product collection(see above) but somehow it was not resetting the collection with new product. WhenI copied that Sql statment in phpMyAdmin, it worked, so how to query that statement from product collection:</p> <pre><code> $stmt = $products-&gt;getConnection('core_write')-&gt;query($products-&gt;getSelect()-&gt;__toString()); while($rows = $stmt-&gt;fetch(PDO::FETCH_ASSOC)){ echo "&lt;br&gt;Product Id ".$rows['entity_id']; } </code></pre></li> <li><p>Instead of using <code>catalog/product</code> entity table I used the flat table - <code>cataloginventory_stock_item</code> to accomplish the same thing </p> <pre><code>$stockItem = new Mage_CatalogInventory_Model_Stock_Item(); $stockItems-&gt;addQtyFilter('&gt;',0); $stockItems-&gt;addFieldToFilter('is_in_stock',array('eq'=&gt;'1')); </code></pre></li> </ol> <p>Now there is a collection of all products with <code>qty &gt; 0</code> and that are in stock.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload