1

I'm creating a custom Grid in Adminhtml which is to list all of the items sold in the past 30 days.

I have the Grid setup, with basic product data being filled. However, I need data such as current stock level and custom attributes etc.

I'm a little new to Magento collections and not sure how to use joins etc to build up my desired collection.

Can anyone assist?

protected function _prepareCollection() {

    $collection = Mage::getResourceModel('sales/order_item_collection')
    ->addAttributeToSelect('*')
    ->join('order', 'order_id=entity_id');

    $this->setCollection($collection);
    return parent::_prepareCollection();
}
2

Magento use Zend_Db_Select select as base. To get just do

$collection->getSelect();

after work with it like with usual Zend_Db_Select

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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