When updating a widget instance programmatically, layout updates are removedCopy a Widget Instance Programmatically, Preserving Layout UpdatesWidget Instance Block BugCreate categories through installerPer Store Widget Instance Block ReferencesUnable to trace when order status for an order is marked complete in MagentoGet Widget Instance TitleHow to create a custom block from billing.phtmlMagento config xml multiple layout updatesSQLSTATE[HY000] : General error: 2013 Lost connection to MySQL server during query in MagentoSQLSTATE[42000] when updating attributes in magento 1 programmaticallyHow to add Widget layout updates field in my custom module admin form Magento 2

Remove sudoers using script

Translating 'Liber'

Secure offsite backup, even in the case of hacker root access

Is it recommended against to open-source the code of a webapp?

Are there any existing monsters I can use as a basis for a baby skeleton statblock?

Why only the fundamental frequency component is said to give useful power?

Did Darth Vader wear the same suit for 20+ years?

How to generate random points without duplication?

Implement Homestuck's Catenative Doomsday Dice Cascader

Can you really not move between grapples/shoves?

Select items in a list that contain criteria

What's the correct term for a waitress in the Middle Ages?

Incremental Ranges!

Java guess the number

How to skip replacing first occurrence of a character in each line?

Does Lightning Network has concept of continuous stream of value?

Etymology of 'calcit(r)are'?

How to make a setting relevant?

Axial Equatorial NMR graph difference

Pushout commutative diagram

siunitx error: Invalid numerical input

When conversion from Integer to Single may lose precision

My coworkers think I had a long honeymoon. Actually I was diagnosed with cancer. How do I talk about it?

When writing an error prompt, should we end the sentence with a exclamation mark or a dot?



When updating a widget instance programmatically, layout updates are removed


Copy a Widget Instance Programmatically, Preserving Layout UpdatesWidget Instance Block BugCreate categories through installerPer Store Widget Instance Block ReferencesUnable to trace when order status for an order is marked complete in MagentoGet Widget Instance TitleHow to create a custom block from billing.phtmlMagento config xml multiple layout updatesSQLSTATE[HY000] : General error: 2013 Lost connection to MySQL server during query in MagentoSQLSTATE[42000] when updating attributes in magento 1 programmaticallyHow to add Widget layout updates field in my custom module admin form Magento 2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I tried to update a widget instance as follows (where /PATH/TO and WIDGET_INSTANCE_ID should be replaced by the actual values:



require_once '/PATH/TO/app/Mage.php';
Mage::app();
$widgetInstance = Mage::getModel('widget/widget_instance');
$widgetInstance->load(WIDGET_INSTANCE_ID);
$widgetInstance->setData('title', 'foo');
$widgetInstance->save();


After executing this code, all layout updates of the widget have been removed.



What could be the cause of this?










share|improve this question






























    4















    I tried to update a widget instance as follows (where /PATH/TO and WIDGET_INSTANCE_ID should be replaced by the actual values:



    require_once '/PATH/TO/app/Mage.php';
    Mage::app();
    $widgetInstance = Mage::getModel('widget/widget_instance');
    $widgetInstance->load(WIDGET_INSTANCE_ID);
    $widgetInstance->setData('title', 'foo');
    $widgetInstance->save();


    After executing this code, all layout updates of the widget have been removed.



    What could be the cause of this?










    share|improve this question


























      4












      4








      4








      I tried to update a widget instance as follows (where /PATH/TO and WIDGET_INSTANCE_ID should be replaced by the actual values:



      require_once '/PATH/TO/app/Mage.php';
      Mage::app();
      $widgetInstance = Mage::getModel('widget/widget_instance');
      $widgetInstance->load(WIDGET_INSTANCE_ID);
      $widgetInstance->setData('title', 'foo');
      $widgetInstance->save();


      After executing this code, all layout updates of the widget have been removed.



      What could be the cause of this?










      share|improve this question
















      I tried to update a widget instance as follows (where /PATH/TO and WIDGET_INSTANCE_ID should be replaced by the actual values:



      require_once '/PATH/TO/app/Mage.php';
      Mage::app();
      $widgetInstance = Mage::getModel('widget/widget_instance');
      $widgetInstance->load(WIDGET_INSTANCE_ID);
      $widgetInstance->setData('title', 'foo');
      $widgetInstance->save();


      After executing this code, all layout updates of the widget have been removed.



      What could be the cause of this?







      magento-1.9 bug widget-instance






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 13 '16 at 11:28







      Aad Mathijssen

















      asked Jul 13 '16 at 11:21









      Aad MathijssenAad Mathijssen

      1,38511122




      1,38511122




















          2 Answers
          2






          active

          oldest

          votes


















          5














          The cause of this issue is that the format of the page_groups field needs a different format for saving than is used available after loading.



          The format needed for saving can be generated from the format after loading by placing the following code somewhere between the load and save calls:



          if ($widgetInstance->getData('page_groups')) 
          $formattedPageGroups = [];
          foreach ($widgetInstance->getData('page_groups') as $pageGroup)
          $pageGroupName = $pageGroup['page_group'];
          $formattedPageGroups[] = [
          'page_group' => $pageGroupName,
          $pageGroupName => [
          'page_id' => $pageGroup['page_id'],
          'layout_handle' => $pageGroup['layout_handle'],
          'for' => $pageGroup['page_for'],
          'block' => $pageGroup['block_reference'],
          'entities' => $pageGroup['entities'],
          'template' => $pageGroup['template']
          ]
          ];

          $widgetInstance->setData('page_groups', $formattedPageGroups);



          Note that this is in essence the same issue as described in the post on copying a widget instance.






          share|improve this answer
































            0














            I think the name of the property is 'page_template' and not 'template' at line:



            'template' => $pageGroup['template']



            should be



            'template' => $pageGroup['page_template']






            share|improve this answer










            New contributor



            DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.



















              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "479"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f125547%2fwhen-updating-a-widget-instance-programmatically-layout-updates-are-removed%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              5














              The cause of this issue is that the format of the page_groups field needs a different format for saving than is used available after loading.



              The format needed for saving can be generated from the format after loading by placing the following code somewhere between the load and save calls:



              if ($widgetInstance->getData('page_groups')) 
              $formattedPageGroups = [];
              foreach ($widgetInstance->getData('page_groups') as $pageGroup)
              $pageGroupName = $pageGroup['page_group'];
              $formattedPageGroups[] = [
              'page_group' => $pageGroupName,
              $pageGroupName => [
              'page_id' => $pageGroup['page_id'],
              'layout_handle' => $pageGroup['layout_handle'],
              'for' => $pageGroup['page_for'],
              'block' => $pageGroup['block_reference'],
              'entities' => $pageGroup['entities'],
              'template' => $pageGroup['template']
              ]
              ];

              $widgetInstance->setData('page_groups', $formattedPageGroups);



              Note that this is in essence the same issue as described in the post on copying a widget instance.






              share|improve this answer





























                5














                The cause of this issue is that the format of the page_groups field needs a different format for saving than is used available after loading.



                The format needed for saving can be generated from the format after loading by placing the following code somewhere between the load and save calls:



                if ($widgetInstance->getData('page_groups')) 
                $formattedPageGroups = [];
                foreach ($widgetInstance->getData('page_groups') as $pageGroup)
                $pageGroupName = $pageGroup['page_group'];
                $formattedPageGroups[] = [
                'page_group' => $pageGroupName,
                $pageGroupName => [
                'page_id' => $pageGroup['page_id'],
                'layout_handle' => $pageGroup['layout_handle'],
                'for' => $pageGroup['page_for'],
                'block' => $pageGroup['block_reference'],
                'entities' => $pageGroup['entities'],
                'template' => $pageGroup['template']
                ]
                ];

                $widgetInstance->setData('page_groups', $formattedPageGroups);



                Note that this is in essence the same issue as described in the post on copying a widget instance.






                share|improve this answer



























                  5












                  5








                  5







                  The cause of this issue is that the format of the page_groups field needs a different format for saving than is used available after loading.



                  The format needed for saving can be generated from the format after loading by placing the following code somewhere between the load and save calls:



                  if ($widgetInstance->getData('page_groups')) 
                  $formattedPageGroups = [];
                  foreach ($widgetInstance->getData('page_groups') as $pageGroup)
                  $pageGroupName = $pageGroup['page_group'];
                  $formattedPageGroups[] = [
                  'page_group' => $pageGroupName,
                  $pageGroupName => [
                  'page_id' => $pageGroup['page_id'],
                  'layout_handle' => $pageGroup['layout_handle'],
                  'for' => $pageGroup['page_for'],
                  'block' => $pageGroup['block_reference'],
                  'entities' => $pageGroup['entities'],
                  'template' => $pageGroup['template']
                  ]
                  ];

                  $widgetInstance->setData('page_groups', $formattedPageGroups);



                  Note that this is in essence the same issue as described in the post on copying a widget instance.






                  share|improve this answer















                  The cause of this issue is that the format of the page_groups field needs a different format for saving than is used available after loading.



                  The format needed for saving can be generated from the format after loading by placing the following code somewhere between the load and save calls:



                  if ($widgetInstance->getData('page_groups')) 
                  $formattedPageGroups = [];
                  foreach ($widgetInstance->getData('page_groups') as $pageGroup)
                  $pageGroupName = $pageGroup['page_group'];
                  $formattedPageGroups[] = [
                  'page_group' => $pageGroupName,
                  $pageGroupName => [
                  'page_id' => $pageGroup['page_id'],
                  'layout_handle' => $pageGroup['layout_handle'],
                  'for' => $pageGroup['page_for'],
                  'block' => $pageGroup['block_reference'],
                  'entities' => $pageGroup['entities'],
                  'template' => $pageGroup['template']
                  ]
                  ];

                  $widgetInstance->setData('page_groups', $formattedPageGroups);



                  Note that this is in essence the same issue as described in the post on copying a widget instance.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 13 '17 at 12:55









                  Community

                  1




                  1










                  answered Jul 13 '16 at 11:41









                  Aad MathijssenAad Mathijssen

                  1,38511122




                  1,38511122























                      0














                      I think the name of the property is 'page_template' and not 'template' at line:



                      'template' => $pageGroup['template']



                      should be



                      'template' => $pageGroup['page_template']






                      share|improve this answer










                      New contributor



                      DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.























                        0














                        I think the name of the property is 'page_template' and not 'template' at line:



                        'template' => $pageGroup['template']



                        should be



                        'template' => $pageGroup['page_template']






                        share|improve this answer










                        New contributor



                        DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.





















                          0












                          0








                          0







                          I think the name of the property is 'page_template' and not 'template' at line:



                          'template' => $pageGroup['template']



                          should be



                          'template' => $pageGroup['page_template']






                          share|improve this answer










                          New contributor



                          DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          I think the name of the property is 'page_template' and not 'template' at line:



                          'template' => $pageGroup['template']



                          should be



                          'template' => $pageGroup['page_template']







                          share|improve this answer










                          New contributor



                          DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          share|improve this answer



                          share|improve this answer








                          edited May 28 at 16:42









                          Daniel

                          895219




                          895219






                          New contributor



                          DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.








                          answered May 28 at 14:17









                          DexBGDexBG

                          1




                          1




                          New contributor



                          DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.




                          New contributor




                          DexBG is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f125547%2fwhen-updating-a-widget-instance-programmatically-layout-updates-are-removed%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                              Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                              Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림