How to show a category's products in shopping cartDoes not show categories or products in homepageHow to show specific category products in cart page?How to display related products on the cart page (checkout)?How can I show the same product multiple times in the shopping cart?Getting category's custom attribute valueHow to determine upsell products in shopping cartShopping cart empties abruptly - cookies not persistingShow last 5 purchase order products details in shopping cart page (like last minuts shopping)How to check shopping cart empty magento 2?custom table data show on shopping cart pageShopping Cart Rules for Mixed ProductsShopping Cart Thumbnails not showing

How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?

How can I detect if I'm in a subshell?

How to address players struggling with simple controls?

Credit card validation in C

What is "dot" sign in •NO?

Can you place a web spell on a surface you cannot see?

Do battery electrons only move if there is a positive terminal at the end of the wire?

Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)

Does knowing the surface area of all faces uniquely determine a tetrahedron?

Is a sequel allowed to start before the end of the first book?

How to avoid offending original culture when making conculture inspired from original

Is the infant mortality rate among African-American babies in Youngstown, Ohio greater than that of babies in Iran?

How to sort human readable size

Explicit song lyrics checker

You may find me... puzzling

Who was the youngest Executive Producer?

Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?

A medieval book with a redhead girl as a main character who allies with vampires and werewolves against scientific opposition

How "fast" do astronomical events occur?

Why we can't jump without bending our knees?

Is it possible to use just one shared folder for log shipping?

I have found ports on my Samsung smart tv running a display service. What can I do with it?

Right indicator flash-frequency has increased and rear-right bulb is out

Harmonic Series Phase Difference?



How to show a category's products in shopping cart


Does not show categories or products in homepageHow to show specific category products in cart page?How to display related products on the cart page (checkout)?How can I show the same product multiple times in the shopping cart?Getting category's custom attribute valueHow to determine upsell products in shopping cartShopping cart empties abruptly - cookies not persistingShow last 5 purchase order products details in shopping cart page (like last minuts shopping)How to check shopping cart empty magento 2?custom table data show on shopping cart pageShopping Cart Rules for Mixed ProductsShopping Cart Thumbnails not showing






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








4















Magento version 2.3



I want to show a particular category in shopping cart page using programming, instead of using backend widget settings.



I have tried to modify the following files with no luck:



Magento_Checkout/layout/checkout_cart_index.xml



<block type="catalog/product_list" category_id="4" template="catalog/product/list.phtml" />


which returns error, it says that block cannot set type attribute



source



Magento_Checkout/templates/cart.phtml



if ($block->getItemsCount()) 
echo $block->getChildHtml('with-items');
$this->getLayout()->createBlock('catalog/product_list')
->setData('category_id','$YourCategoryId')
->setTemplate('catalog/product/list.phtml')->toHtml();
else
echo $block->getChildHtml('no-items');



returns error code 500



source










share|improve this question









New contributor



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

























    4















    Magento version 2.3



    I want to show a particular category in shopping cart page using programming, instead of using backend widget settings.



    I have tried to modify the following files with no luck:



    Magento_Checkout/layout/checkout_cart_index.xml



    <block type="catalog/product_list" category_id="4" template="catalog/product/list.phtml" />


    which returns error, it says that block cannot set type attribute



    source



    Magento_Checkout/templates/cart.phtml



    if ($block->getItemsCount()) 
    echo $block->getChildHtml('with-items');
    $this->getLayout()->createBlock('catalog/product_list')
    ->setData('category_id','$YourCategoryId')
    ->setTemplate('catalog/product/list.phtml')->toHtml();
    else
    echo $block->getChildHtml('no-items');



    returns error code 500



    source










    share|improve this question









    New contributor



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





















      4












      4








      4








      Magento version 2.3



      I want to show a particular category in shopping cart page using programming, instead of using backend widget settings.



      I have tried to modify the following files with no luck:



      Magento_Checkout/layout/checkout_cart_index.xml



      <block type="catalog/product_list" category_id="4" template="catalog/product/list.phtml" />


      which returns error, it says that block cannot set type attribute



      source



      Magento_Checkout/templates/cart.phtml



      if ($block->getItemsCount()) 
      echo $block->getChildHtml('with-items');
      $this->getLayout()->createBlock('catalog/product_list')
      ->setData('category_id','$YourCategoryId')
      ->setTemplate('catalog/product/list.phtml')->toHtml();
      else
      echo $block->getChildHtml('no-items');



      returns error code 500



      source










      share|improve this question









      New contributor



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











      Magento version 2.3



      I want to show a particular category in shopping cart page using programming, instead of using backend widget settings.



      I have tried to modify the following files with no luck:



      Magento_Checkout/layout/checkout_cart_index.xml



      <block type="catalog/product_list" category_id="4" template="catalog/product/list.phtml" />


      which returns error, it says that block cannot set type attribute



      source



      Magento_Checkout/templates/cart.phtml



      if ($block->getItemsCount()) 
      echo $block->getChildHtml('with-items');
      $this->getLayout()->createBlock('catalog/product_list')
      ->setData('category_id','$YourCategoryId')
      ->setTemplate('catalog/product/list.phtml')->toHtml();
      else
      echo $block->getChildHtml('no-items');



      returns error code 500



      source







      product checkout category cart magento2.3






      share|improve this question









      New contributor



      wltprgm 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 question









      New contributor



      wltprgm 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 question




      share|improve this question








      edited yesterday









      Aasim Goriya

      3,19211141




      3,19211141






      New contributor



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








      asked Jun 10 at 4:26









      wltprgmwltprgm

      214




      214




      New contributor



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




      New contributor




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






















          3 Answers
          3






          active

          oldest

          votes


















          2














          Try below code in your



          Magento_Checkout/layout/checkout_cart_index.xml



          <block type="MagentoCatalogBlockProductListProduct" category_id="4" template="catalog/product/list.phtml" />



          Magento_Checkout/templates/cart.phtml:




          $YourCategoryId = $this->getData("category_id");
          if ($block->getItemsCount())
          echo $block->getChildHtml('with-items');
          $this->getLayout()->createBlock('catalog/product_list')
          ->setData('category_id',$YourCategoryId)
          ->setTemplate('catalog/product/list.phtml')->toHtml();
          else
          echo $block->getChildHtml('no-items');






          share|improve this answer

























          • 2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

            – wltprgm
            Jun 10 at 7:17











          • Check updated answer.

            – Mohit chauhan
            Jun 10 at 7:21











          • Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

            – wltprgm
            Jun 10 at 7:37


















          1














          In addition to display the specific category wise products on Cart page,
          you need to include following code




          vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml (Override the module as per your convinience)




          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
          <arguments>
          <argument name="category_id" xsi:type="number">3</argument>
          </arguments>
          </block>


          Note :



          1. In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.

          2. In Above code "3" is the category id, Change the category id as per your requirement.





          share|improve this answer























          • Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

            – wltprgm
            Jun 10 at 8:22












          • I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

            – wltprgm
            Jun 10 at 8:25











          • An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

            – wltprgm
            Jun 10 at 8:27


















          0














          I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom



          enter image description here



          Update 2
          I follow your activity I got you are using Magento 2 CMS, but you are using Block type and code style of Magento 1. which this option you should use.
          MagentoCatalogBlockProductListProduct instead of catalogproduct_list



          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          If you need to customer order product collection by own. You need to create new Block extends MagentoCatalogBlockProductListProduct
          and custom _getProductCollection function.



          New Block XML



          <block class="NamespaceModuleNameBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          NamespaceModuleNameBlockProductListProduct



          protected function _getProductCollection()

          if ($this->_productCollection === null)
          $this->_productCollection = $this->initializeProductCollection();
          $this->_productCollection->setOrder('[attribute code]', 'desc');


          return $this->_productCollection;






          share|improve this answer

























          • I modified my question, I need to solve this programmatically, in order to achieve certain feature

            – wltprgm
            Jun 12 at 2:10











          • Updated answer. You need to define Magento Version you have used.

            – HoangHieu
            Jun 12 at 2:52











          • What does this sentence means? "If you need to customer order product collection by own."

            – wltprgm
            Jun 12 at 3:39












          • How do I create new block? in what folder? app/code, app/design?

            – wltprgm
            Jun 12 at 3:39











          • You need to learn how to create block Magento 2 first.

            – HoangHieu
            Jun 12 at 4:07











          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
          );



          );






          wltprgm is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277750%2fhow-to-show-a-categorys-products-in-shopping-cart%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









          2














          Try below code in your



          Magento_Checkout/layout/checkout_cart_index.xml



          <block type="MagentoCatalogBlockProductListProduct" category_id="4" template="catalog/product/list.phtml" />



          Magento_Checkout/templates/cart.phtml:




          $YourCategoryId = $this->getData("category_id");
          if ($block->getItemsCount())
          echo $block->getChildHtml('with-items');
          $this->getLayout()->createBlock('catalog/product_list')
          ->setData('category_id',$YourCategoryId)
          ->setTemplate('catalog/product/list.phtml')->toHtml();
          else
          echo $block->getChildHtml('no-items');






          share|improve this answer

























          • 2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

            – wltprgm
            Jun 10 at 7:17











          • Check updated answer.

            – Mohit chauhan
            Jun 10 at 7:21











          • Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

            – wltprgm
            Jun 10 at 7:37















          2














          Try below code in your



          Magento_Checkout/layout/checkout_cart_index.xml



          <block type="MagentoCatalogBlockProductListProduct" category_id="4" template="catalog/product/list.phtml" />



          Magento_Checkout/templates/cart.phtml:




          $YourCategoryId = $this->getData("category_id");
          if ($block->getItemsCount())
          echo $block->getChildHtml('with-items');
          $this->getLayout()->createBlock('catalog/product_list')
          ->setData('category_id',$YourCategoryId)
          ->setTemplate('catalog/product/list.phtml')->toHtml();
          else
          echo $block->getChildHtml('no-items');






          share|improve this answer

























          • 2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

            – wltprgm
            Jun 10 at 7:17











          • Check updated answer.

            – Mohit chauhan
            Jun 10 at 7:21











          • Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

            – wltprgm
            Jun 10 at 7:37













          2












          2








          2







          Try below code in your



          Magento_Checkout/layout/checkout_cart_index.xml



          <block type="MagentoCatalogBlockProductListProduct" category_id="4" template="catalog/product/list.phtml" />



          Magento_Checkout/templates/cart.phtml:




          $YourCategoryId = $this->getData("category_id");
          if ($block->getItemsCount())
          echo $block->getChildHtml('with-items');
          $this->getLayout()->createBlock('catalog/product_list')
          ->setData('category_id',$YourCategoryId)
          ->setTemplate('catalog/product/list.phtml')->toHtml();
          else
          echo $block->getChildHtml('no-items');






          share|improve this answer















          Try below code in your



          Magento_Checkout/layout/checkout_cart_index.xml



          <block type="MagentoCatalogBlockProductListProduct" category_id="4" template="catalog/product/list.phtml" />



          Magento_Checkout/templates/cart.phtml:




          $YourCategoryId = $this->getData("category_id");
          if ($block->getItemsCount())
          echo $block->getChildHtml('with-items');
          $this->getLayout()->createBlock('catalog/product_list')
          ->setData('category_id',$YourCategoryId)
          ->setTemplate('catalog/product/list.phtml')->toHtml();
          else
          echo $block->getChildHtml('no-items');







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 10 at 7:21

























          answered Jun 10 at 6:48









          Mohit chauhanMohit chauhan

          680212




          680212












          • 2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

            – wltprgm
            Jun 10 at 7:17











          • Check updated answer.

            – Mohit chauhan
            Jun 10 at 7:21











          • Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

            – wltprgm
            Jun 10 at 7:37

















          • 2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

            – wltprgm
            Jun 10 at 7:17











          • Check updated answer.

            – Mohit chauhan
            Jun 10 at 7:21











          • Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

            – wltprgm
            Jun 10 at 7:37
















          2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

          – wltprgm
          Jun 10 at 7:17





          2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist

          – wltprgm
          Jun 10 at 7:17













          Check updated answer.

          – Mohit chauhan
          Jun 10 at 7:21





          Check updated answer.

          – Mohit chauhan
          Jun 10 at 7:21













          Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

          – wltprgm
          Jun 10 at 7:37





          Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…

          – wltprgm
          Jun 10 at 7:37













          1














          In addition to display the specific category wise products on Cart page,
          you need to include following code




          vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml (Override the module as per your convinience)




          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
          <arguments>
          <argument name="category_id" xsi:type="number">3</argument>
          </arguments>
          </block>


          Note :



          1. In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.

          2. In Above code "3" is the category id, Change the category id as per your requirement.





          share|improve this answer























          • Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

            – wltprgm
            Jun 10 at 8:22












          • I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

            – wltprgm
            Jun 10 at 8:25











          • An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

            – wltprgm
            Jun 10 at 8:27















          1














          In addition to display the specific category wise products on Cart page,
          you need to include following code




          vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml (Override the module as per your convinience)




          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
          <arguments>
          <argument name="category_id" xsi:type="number">3</argument>
          </arguments>
          </block>


          Note :



          1. In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.

          2. In Above code "3" is the category id, Change the category id as per your requirement.





          share|improve this answer























          • Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

            – wltprgm
            Jun 10 at 8:22












          • I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

            – wltprgm
            Jun 10 at 8:25











          • An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

            – wltprgm
            Jun 10 at 8:27













          1












          1








          1







          In addition to display the specific category wise products on Cart page,
          you need to include following code




          vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml (Override the module as per your convinience)




          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
          <arguments>
          <argument name="category_id" xsi:type="number">3</argument>
          </arguments>
          </block>


          Note :



          1. In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.

          2. In Above code "3" is the category id, Change the category id as per your requirement.





          share|improve this answer













          In addition to display the specific category wise products on Cart page,
          you need to include following code




          vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml (Override the module as per your convinience)




          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" template="Magento_Catalog::product/list.phtml">
          <arguments>
          <argument name="category_id" xsi:type="number">3</argument>
          </arguments>
          </block>


          Note :



          1. In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.

          2. In Above code "3" is the category id, Change the category id as per your requirement.






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 10 at 8:15









          oscprofessionalsoscprofessionals

          40927




          40927












          • Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

            – wltprgm
            Jun 10 at 8:22












          • I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

            – wltprgm
            Jun 10 at 8:25











          • An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

            – wltprgm
            Jun 10 at 8:27

















          • Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

            – wltprgm
            Jun 10 at 8:22












          • I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

            – wltprgm
            Jun 10 at 8:25











          • An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

            – wltprgm
            Jun 10 at 8:27
















          Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

          – wltprgm
          Jun 10 at 8:22






          Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list

          – wltprgm
          Jun 10 at 8:22














          I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

          – wltprgm
          Jun 10 at 8:25





          I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.

          – wltprgm
          Jun 10 at 8:25













          An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

          – wltprgm
          Jun 10 at 8:27





          An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197

          – wltprgm
          Jun 10 at 8:27











          0














          I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom



          enter image description here



          Update 2
          I follow your activity I got you are using Magento 2 CMS, but you are using Block type and code style of Magento 1. which this option you should use.
          MagentoCatalogBlockProductListProduct instead of catalogproduct_list



          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          If you need to customer order product collection by own. You need to create new Block extends MagentoCatalogBlockProductListProduct
          and custom _getProductCollection function.



          New Block XML



          <block class="NamespaceModuleNameBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          NamespaceModuleNameBlockProductListProduct



          protected function _getProductCollection()

          if ($this->_productCollection === null)
          $this->_productCollection = $this->initializeProductCollection();
          $this->_productCollection->setOrder('[attribute code]', 'desc');


          return $this->_productCollection;






          share|improve this answer

























          • I modified my question, I need to solve this programmatically, in order to achieve certain feature

            – wltprgm
            Jun 12 at 2:10











          • Updated answer. You need to define Magento Version you have used.

            – HoangHieu
            Jun 12 at 2:52











          • What does this sentence means? "If you need to customer order product collection by own."

            – wltprgm
            Jun 12 at 3:39












          • How do I create new block? in what folder? app/code, app/design?

            – wltprgm
            Jun 12 at 3:39











          • You need to learn how to create block Magento 2 first.

            – HoangHieu
            Jun 12 at 4:07















          0














          I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom



          enter image description here



          Update 2
          I follow your activity I got you are using Magento 2 CMS, but you are using Block type and code style of Magento 1. which this option you should use.
          MagentoCatalogBlockProductListProduct instead of catalogproduct_list



          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          If you need to customer order product collection by own. You need to create new Block extends MagentoCatalogBlockProductListProduct
          and custom _getProductCollection function.



          New Block XML



          <block class="NamespaceModuleNameBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          NamespaceModuleNameBlockProductListProduct



          protected function _getProductCollection()

          if ($this->_productCollection === null)
          $this->_productCollection = $this->initializeProductCollection();
          $this->_productCollection->setOrder('[attribute code]', 'desc');


          return $this->_productCollection;






          share|improve this answer

























          • I modified my question, I need to solve this programmatically, in order to achieve certain feature

            – wltprgm
            Jun 12 at 2:10











          • Updated answer. You need to define Magento Version you have used.

            – HoangHieu
            Jun 12 at 2:52











          • What does this sentence means? "If you need to customer order product collection by own."

            – wltprgm
            Jun 12 at 3:39












          • How do I create new block? in what folder? app/code, app/design?

            – wltprgm
            Jun 12 at 3:39











          • You need to learn how to create block Magento 2 first.

            – HoangHieu
            Jun 12 at 4:07













          0












          0








          0







          I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom



          enter image description here



          Update 2
          I follow your activity I got you are using Magento 2 CMS, but you are using Block type and code style of Magento 1. which this option you should use.
          MagentoCatalogBlockProductListProduct instead of catalogproduct_list



          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          If you need to customer order product collection by own. You need to create new Block extends MagentoCatalogBlockProductListProduct
          and custom _getProductCollection function.



          New Block XML



          <block class="NamespaceModuleNameBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          NamespaceModuleNameBlockProductListProduct



          protected function _getProductCollection()

          if ($this->_productCollection === null)
          $this->_productCollection = $this->initializeProductCollection();
          $this->_productCollection->setOrder('[attribute code]', 'desc');


          return $this->_productCollection;






          share|improve this answer















          I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom



          enter image description here



          Update 2
          I follow your activity I got you are using Magento 2 CMS, but you are using Block type and code style of Magento 1. which this option you should use.
          MagentoCatalogBlockProductListProduct instead of catalogproduct_list



          <block class="MagentoCatalogBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          If you need to customer order product collection by own. You need to create new Block extends MagentoCatalogBlockProductListProduct
          and custom _getProductCollection function.



          New Block XML



          <block class="NamespaceModuleNameBlockProductListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
          <action method="setToolbarBlockName">
          <argument name="category_id" xsi:type="number">[category id]</argument>
          </action>
          </block>


          NamespaceModuleNameBlockProductListProduct



          protected function _getProductCollection()

          if ($this->_productCollection === null)
          $this->_productCollection = $this->initializeProductCollection();
          $this->_productCollection->setOrder('[attribute code]', 'desc');


          return $this->_productCollection;







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 12 at 2:50

























          answered Jun 10 at 8:20









          HoangHieuHoangHieu

          774515




          774515












          • I modified my question, I need to solve this programmatically, in order to achieve certain feature

            – wltprgm
            Jun 12 at 2:10











          • Updated answer. You need to define Magento Version you have used.

            – HoangHieu
            Jun 12 at 2:52











          • What does this sentence means? "If you need to customer order product collection by own."

            – wltprgm
            Jun 12 at 3:39












          • How do I create new block? in what folder? app/code, app/design?

            – wltprgm
            Jun 12 at 3:39











          • You need to learn how to create block Magento 2 first.

            – HoangHieu
            Jun 12 at 4:07

















          • I modified my question, I need to solve this programmatically, in order to achieve certain feature

            – wltprgm
            Jun 12 at 2:10











          • Updated answer. You need to define Magento Version you have used.

            – HoangHieu
            Jun 12 at 2:52











          • What does this sentence means? "If you need to customer order product collection by own."

            – wltprgm
            Jun 12 at 3:39












          • How do I create new block? in what folder? app/code, app/design?

            – wltprgm
            Jun 12 at 3:39











          • You need to learn how to create block Magento 2 first.

            – HoangHieu
            Jun 12 at 4:07
















          I modified my question, I need to solve this programmatically, in order to achieve certain feature

          – wltprgm
          Jun 12 at 2:10





          I modified my question, I need to solve this programmatically, in order to achieve certain feature

          – wltprgm
          Jun 12 at 2:10













          Updated answer. You need to define Magento Version you have used.

          – HoangHieu
          Jun 12 at 2:52





          Updated answer. You need to define Magento Version you have used.

          – HoangHieu
          Jun 12 at 2:52













          What does this sentence means? "If you need to customer order product collection by own."

          – wltprgm
          Jun 12 at 3:39






          What does this sentence means? "If you need to customer order product collection by own."

          – wltprgm
          Jun 12 at 3:39














          How do I create new block? in what folder? app/code, app/design?

          – wltprgm
          Jun 12 at 3:39





          How do I create new block? in what folder? app/code, app/design?

          – wltprgm
          Jun 12 at 3:39













          You need to learn how to create block Magento 2 first.

          – HoangHieu
          Jun 12 at 4:07





          You need to learn how to create block Magento 2 first.

          – HoangHieu
          Jun 12 at 4:07










          wltprgm is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          wltprgm is a new contributor. Be nice, and check out our Code of Conduct.












          wltprgm is a new contributor. Be nice, and check out our Code of Conduct.











          wltprgm is a new contributor. Be nice, and check out our Code of Conduct.














          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%2f277750%2fhow-to-show-a-categorys-products-in-shopping-cart%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?