2

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';
0

For Cms Block

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

after That you can get data like below code

print_r($cms_block_collection->getData())

For Widget You can use below collection

$collection = Mage::getModel('widget/widget_instance')->getCollection();
$collection->getSelect()
 ->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! – Shiran S Ekanayake Sep 28 '16 at 6:42
  • You are always Welcome :) – Murtuza Zabuawala Sep 28 '16 at 6:44

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.