I added a custom grid in admin panel which shows all the Best seller product collections. (configurable products). The admin grid has the following columns:

entity_id     product_name    sku      ordered_qty

I am getting the Best seller product collection by using Mage::getResourceModel('reports/product_collection'); but while filling the admin grid, I am changing the product collection to related to catalog product collection. as shown below:

protected function _prepareCollection()
    $from = /* some date */;
    $to = /* some date */;

    $collection = Mage::getResourceModel('reports/product_collection')
        ->addOrderedQty($from, $to)

    $common_ids = array();

    foreach($collection as $product) {
        $common_ids[] = $product->getId();

    $collection = Mage::getResourceModel('catalog/product_collection')
        ->addFieldToFilter('entity_id', $common_ids)
        ->addAttributeToSort('created_at', 'desc');
    return $this;

As you can see in the above code, I am getting the product collection twice because the "reports/product_collection" is not filling the admin grid. So, I did "catalog/product_collection" again to the collection which is filling the admin grid.

But "catalog/product_collection" is not filling the column ordered_qty because the ordered_qty column values are being prepared by "reports/product_collection".

How should I get the values for ordered_qty ?

  • please let me know if you can't understand my explanation.
    – Mr_Green
    May 21, 2014 at 11:48

1 Answer 1


You are already getting the ordered_qty from the first collection.
You can remember them in an array by id and attach them to the second collection after calling parent::_prepareCollection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.