Display Widget in phtml file magento 2Magento 2: Call a Widget in .phtml fileHow to call widget with products of specific category in “.phtml” file?Magento 2: Call a Widget in .phtml fileMagento2 Recently viewed widget not workingRecently viewed widget display nothing - Magento 2.0.8Magento 2: Display Product ImageHow to call widget with products of specific category in “.phtml” file?Magento 2 Widget Condition on edit not displayMagento 2 - Best approach to display and customize Recently Viewed Products with sliderCustomizing the insert widget type 'Catalog Products List' templateHow can i edit recently viewed products widget layout?Own recently viewed widget (magento 2)

How to reduce predictors the right way for a logistic regression model

How do I Interface a PS/2 Keyboard without Modern Techniques?

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

Why the "ls" command is showing the permissions of files in a FAT32 partition?

Why Shazam when there is already Superman?

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Check if object is null and return null

How to preserve electronics (computers, iPads and phones) for hundreds of years

How would a solely written language work mechanically

What is the meaning of "You've never met a graph you didn't like?"

How to leave product feedback on macOS?

Visualizing the difference curve in a 2D plot?

What should be the ideal length of sentences in a blog post for ease of reading?

What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?

I'm just a whisper. Who am I?

Echo with obfuscation

What is the meaning of the following sentence?

Make a Bowl of Alphabet Soup

Anime with legendary swords made from talismans and a man who could change them with a shattered body

Does Doodling or Improvising on the Piano Have Any Benefits?

Showing mass murder in a kid's book

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Why didn’t Eve recognize the little cockroach as a living organism?

Why is participating in the European Parliamentary elections used as a threat?



Display Widget in phtml file magento 2


Magento 2: Call a Widget in .phtml fileHow to call widget with products of specific category in “.phtml” file?Magento 2: Call a Widget in .phtml fileMagento2 Recently viewed widget not workingRecently viewed widget display nothing - Magento 2.0.8Magento 2: Display Product ImageHow to call widget with products of specific category in “.phtml” file?Magento 2 Widget Condition on edit not displayMagento 2 - Best approach to display and customize Recently Viewed Products with sliderCustomizing the insert widget type 'Catalog Products List' templateHow can i edit recently viewed products widget layout?Own recently viewed widget (magento 2)













0















I have Following widget and its working in cms page but now I want it to display in phtml file



widget type="MagentoCatalogBlockWidgetRecentlyViewed" uiComponent="widget_recently_viewed" page_size="10" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/grid.phtml" type_name="Recently Viewed Products"









share|improve this question






















  • magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

    – Prathap Gunasekaran
    yesterday











  • @PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

    – Harsh Jayswal
    yesterday















0















I have Following widget and its working in cms page but now I want it to display in phtml file



widget type="MagentoCatalogBlockWidgetRecentlyViewed" uiComponent="widget_recently_viewed" page_size="10" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/grid.phtml" type_name="Recently Viewed Products"









share|improve this question






















  • magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

    – Prathap Gunasekaran
    yesterday











  • @PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

    – Harsh Jayswal
    yesterday













0












0








0


0






I have Following widget and its working in cms page but now I want it to display in phtml file



widget type="MagentoCatalogBlockWidgetRecentlyViewed" uiComponent="widget_recently_viewed" page_size="10" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/grid.phtml" type_name="Recently Viewed Products"









share|improve this question














I have Following widget and its working in cms page but now I want it to display in phtml file



widget type="MagentoCatalogBlockWidgetRecentlyViewed" uiComponent="widget_recently_viewed" page_size="10" show_attributes="name,image,price,learn_more" show_buttons="add_to_cart,add_to_compare,add_to_wishlist" template="product/widget/viewed/grid.phtml" type_name="Recently Viewed Products"






magento2 magento-2.1 product magento2.3 widgets






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Harsh JayswalHarsh Jayswal

799




799












  • magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

    – Prathap Gunasekaran
    yesterday











  • @PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

    – Harsh Jayswal
    yesterday

















  • magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

    – Prathap Gunasekaran
    yesterday











  • @PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

    – Harsh Jayswal
    yesterday
















magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

– Prathap Gunasekaran
yesterday





magento.stackexchange.com/questions/107750/… Try this @HarshJayswal

– Prathap Gunasekaran
yesterday













@PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

– Harsh Jayswal
yesterday





@PrathapGunasekaran have already tried but it shows an error if you know how to set my widget according to that answer than please post the answer

– Harsh Jayswal
yesterday










3 Answers
3






active

oldest

votes


















1














Try with below way.



$recViewBlock = $this->getLayout()->createBlock(MagentoCatalogBlockWidgetRecentlyViewed::class);
$recViewBlock->setTitle("Recently Viewed Products");
$recViewBlock->setProductsCount(10);
$recViewBlock->setTemplate("product/widget/viewed/grid.phtml");
$recViewBlock->setDisplayType("recently.view.products");
$recViewBlock->setShowAttribute(add_to_cart,add_to_compare,add_to_wishlist);

echo $recViewBlock->toHtml();


Note : Above code is not tested you have to check. For more detail click here



I hope it helps!






share|improve this answer























  • thanks for your answer but is shows error

    – Harsh Jayswal
    17 hours ago


















0














phtml file :-



<?php echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("widget_recently_viewed")->setProductsCount("5")->setTemplate("product/widget/viewed/grid.phtml")->toHtml(); ?>





share|improve this answer






























    0














    Try this :



    echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("your_display_type")->toHtml();





    share|improve this answer






















      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%2f266598%2fdisplay-widget-in-phtml-file-magento-2%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Try with below way.



      $recViewBlock = $this->getLayout()->createBlock(MagentoCatalogBlockWidgetRecentlyViewed::class);
      $recViewBlock->setTitle("Recently Viewed Products");
      $recViewBlock->setProductsCount(10);
      $recViewBlock->setTemplate("product/widget/viewed/grid.phtml");
      $recViewBlock->setDisplayType("recently.view.products");
      $recViewBlock->setShowAttribute(add_to_cart,add_to_compare,add_to_wishlist);

      echo $recViewBlock->toHtml();


      Note : Above code is not tested you have to check. For more detail click here



      I hope it helps!






      share|improve this answer























      • thanks for your answer but is shows error

        – Harsh Jayswal
        17 hours ago















      1














      Try with below way.



      $recViewBlock = $this->getLayout()->createBlock(MagentoCatalogBlockWidgetRecentlyViewed::class);
      $recViewBlock->setTitle("Recently Viewed Products");
      $recViewBlock->setProductsCount(10);
      $recViewBlock->setTemplate("product/widget/viewed/grid.phtml");
      $recViewBlock->setDisplayType("recently.view.products");
      $recViewBlock->setShowAttribute(add_to_cart,add_to_compare,add_to_wishlist);

      echo $recViewBlock->toHtml();


      Note : Above code is not tested you have to check. For more detail click here



      I hope it helps!






      share|improve this answer























      • thanks for your answer but is shows error

        – Harsh Jayswal
        17 hours ago













      1












      1








      1







      Try with below way.



      $recViewBlock = $this->getLayout()->createBlock(MagentoCatalogBlockWidgetRecentlyViewed::class);
      $recViewBlock->setTitle("Recently Viewed Products");
      $recViewBlock->setProductsCount(10);
      $recViewBlock->setTemplate("product/widget/viewed/grid.phtml");
      $recViewBlock->setDisplayType("recently.view.products");
      $recViewBlock->setShowAttribute(add_to_cart,add_to_compare,add_to_wishlist);

      echo $recViewBlock->toHtml();


      Note : Above code is not tested you have to check. For more detail click here



      I hope it helps!






      share|improve this answer













      Try with below way.



      $recViewBlock = $this->getLayout()->createBlock(MagentoCatalogBlockWidgetRecentlyViewed::class);
      $recViewBlock->setTitle("Recently Viewed Products");
      $recViewBlock->setProductsCount(10);
      $recViewBlock->setTemplate("product/widget/viewed/grid.phtml");
      $recViewBlock->setDisplayType("recently.view.products");
      $recViewBlock->setShowAttribute(add_to_cart,add_to_compare,add_to_wishlist);

      echo $recViewBlock->toHtml();


      Note : Above code is not tested you have to check. For more detail click here



      I hope it helps!







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 20 hours ago









      Chirag PatelChirag Patel

      2,368423




      2,368423












      • thanks for your answer but is shows error

        – Harsh Jayswal
        17 hours ago

















      • thanks for your answer but is shows error

        – Harsh Jayswal
        17 hours ago
















      thanks for your answer but is shows error

      – Harsh Jayswal
      17 hours ago





      thanks for your answer but is shows error

      – Harsh Jayswal
      17 hours ago













      0














      phtml file :-



      <?php echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("widget_recently_viewed")->setProductsCount("5")->setTemplate("product/widget/viewed/grid.phtml")->toHtml(); ?>





      share|improve this answer



























        0














        phtml file :-



        <?php echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("widget_recently_viewed")->setProductsCount("5")->setTemplate("product/widget/viewed/grid.phtml")->toHtml(); ?>





        share|improve this answer

























          0












          0








          0







          phtml file :-



          <?php echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("widget_recently_viewed")->setProductsCount("5")->setTemplate("product/widget/viewed/grid.phtml")->toHtml(); ?>





          share|improve this answer













          phtml file :-



          <?php echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("widget_recently_viewed")->setProductsCount("5")->setTemplate("product/widget/viewed/grid.phtml")->toHtml(); ?>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          Ronak RathodRonak Rathod

          54610




          54610





















              0














              Try this :



              echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("your_display_type")->toHtml();





              share|improve this answer



























                0














                Try this :



                echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("your_display_type")->toHtml();





                share|improve this answer

























                  0












                  0








                  0







                  Try this :



                  echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("your_display_type")->toHtml();





                  share|improve this answer













                  Try this :



                  echo $this->getLayout()->createBlock("MagentoCatalogBlockWidgetRecentlyViewed")->setDisplayType("your_display_type")->toHtml();






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  rohan.katkarrohan.katkar

                  1429




                  1429



























                      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%2f266598%2fdisplay-widget-in-phtml-file-magento-2%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

                      Sum ergo cogito? 1 nng

                      419 nièngy_Soadمي 19bal1.5o_g

                      Queiggey Chernihivv 9NnOo i Zw X QqKk LpB