Вопрос

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';
Это было полезно?

Решение

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");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top