Search code examples
magentoflat

How to select from magento EAV tables when flat catalog product data is on


I have this code for selecting best selling products from Magento:

$productCollection = Mage::getResourceModel('reports/product_collection')
            ->addOrderedQty($startTime, $currentTime)
            ->addAttributeToSelect('*')
            ->setStoreId($storeId)
            ->addStoreFilter($storeId)
            ->setOrder('ordered_qty', 'desc')
            ->setPageSize($this->limit());
    }

and it works fine, until I set "use flat catalog product" in backend to yes. Is there any way to tell magento to not use flat tables, and use EAV instead?
Can any one help me with this.


Solution

  • Create a new model class ('mycatalog/product') that extends the original product class but hard code it to use the EAV resource model and EAV resource collection, and then use that model in your query code.