I am having magento site with more then 80 widgets, now i am looking to change theme , with new package name and theme(here i have two themes for mobile and desktop). what is the best way to copy widgets to current two themes?

Thanks in advance!!!

2 Answers 2


Best idea is change theme programatically getting all widget using

$collection = Mage::getModel('widget/widget_instance')->getCollection();

than change theme whatever you want

  • Thx bro, i followed same way what you updated. i have changed some other things as my requirement. Sep 27, 2017 at 14:15
  • please accept my answer if it useful for you Sep 28, 2017 at 4:44
  • How can I get all widget instances in Magento 2? I guess the answer is for Magento 1. Nov 1, 2017 at 16:20
//for specific widgets , use array
//use Mage::getModel('widget/widget_instance')->getCollection(); for all widgets
foreach($widgets as $widget)
  echo "<br>=================================".$widget;
  $widget = Mage::getModel('widget/widget_instance')->load($widget);
  unset($data['instance_id']);//for creating keep this one , for update comment this line
  $new_page_groups = array();
  foreach($data['page_groups'] as $group) {
      $page_group_name = $group['page_group']; // i.e. 'anchor_categories', 'simple_products'
      $new_group = array(
          'page_group' => $page_group_name,
           $page_group_name => array(
               'page_id' => $group['page_id'],
               'layout_handle' => $group['layout_handle'],
               'entities' => $group['entities'],
               'for' => $group['page_for'],
               'block' => $group['block_reference'],
               'template' => $group['page_template'],
      $new_page_groups[] = $new_group;
    $data['page_groups'] = $new_page_groups;
    $newWidgetinstance = Mage::getModel('widget/widget_instance')->setData($data)->save();
  • Does this work also in Magento 2? Oct 31, 2017 at 12:43

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.