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!!!
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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!!!
Best idea is change theme programatically getting all widget using
$collection = Mage::getModel('widget/widget_instance')->getCollection();
than change theme whatever you want
//for specific widgets , use array
//use Mage::getModel('widget/widget_instance')->getCollection(); for all widgets
$widgets=[1105,1103,1119,1147,537,1136,1095,1096];
foreach($widgets as $widget)
{
echo "<br>=================================".$widget;
$widget = Mage::getModel('widget/widget_instance')->load($widget);
$data=$widget->getData();
$data['package_theme']='pkg/theme';
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();
print_r($newWidgetinstance->getData());
}