I have some sql queries and I need to get the same data returned by those queries, using Magento models. Since I'm very new to Magento, I don't know how to do this. Following are the sql queries.

SELECT * FROM widget_instance wi, widget_instance_page wip WHERE wi.instance_id = wip.instance_id";

SELECT identifier FROM cms_block WHERE block_id = '2';

1 Answer 1


For Cms Block

$cms_block_collection = Mage::getModel('cms/block')->load(2);

after That you can get data like below code


For Widget You can use below collection

$collection = Mage::getModel('widget/widget_instance')->getCollection();
 ->join(array("wip" => "widget_instance_page"), "main_table.instance_id = wip.instance_id");
  • 1
    Thank you very much for the quick answer. This saved my time! Commented Sep 28, 2016 at 6:42
  • You are always Welcome :) Commented Sep 28, 2016 at 6:44

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.