Skip to content

Instantly share code, notes, and snippets.

@roman204
Last active August 29, 2015 14:03
Show Gist options
  • Save roman204/4d1f2c3e78e921e0964f to your computer and use it in GitHub Desktop.
Save roman204/4d1f2c3e78e921e0964f to your computer and use it in GitHub Desktop.
Magento load widget by title
private function getWidgetByTitleFilter($filter)
{
$collection = Mage::getModel('widget/widget_instance')->getCollection();
$collection->addStoreFilter(Mage::app()->getStore()->getId(), false)
->addFieldToFilter('title', $filter)->load();
$widget = $collection->getFirstItem();
if($widget && is_numeric($widget->getId())) {
$widgetBlock = Mage::app()->getLayout()
->createBlock(
$widget->getType(),
$widget->getTitle(),
$widget->getWidgetParameters()
);
return $widgetBlock;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment