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

What is the difference between x RadToDeg cos x div and COSC?

What does Mildred mean by this line in Three Billboards Outside Ebbing, Missouri?

Averting Real Women Don’t Wear Dresses

"Plugged in" or "Plugged in in"

How should I behave to assure my friends that I am not after their money?

Does the UK have a written constitution?

Can a US President have someone sent to prison?

POSIX Shell Grammar: Why Brace Group Needs First Space But Subshell Doesn't?

How was film developed in the late 1920s?

In native German words, is Q always followed by U, as in English?

In which public key encryption algorithms are the private and public key not reversible?

Analog is Obtuse!

Quacks of Quedlingburg Crow Skull Set 2 Keep Drawing

How to determine what is the correct level of detail when modelling?

Does “comme on était à New York” mean “since” or “as though”?

Should the Torah be covered or uncovered during the Aliyah blessings?

UV emitting alien species

Do sudoku answers always have a single minimal clue set?

One folder two different locations on ubuntu 18.04

Was touching your nose a greeting in second millenium Mesopotamia?

What does grep -v "grep" mean and do?

What exactly is a fey/fiend/celestial spirit?

What is a macro? Difference between macro and function?

Spicket or spigot?



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






























    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


























      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
















      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















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 14 at 13:21









      Aasim Goriya

      3,2371 gold badge11 silver badges43 bronze badges




      3,2371 gold badge11 silver badges43 bronze badges










      asked Jun 10 at 4:26









      wltprgmwltprgm

      265 bronze badges




      265 bronze badges




















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



          );













          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

          6802 silver badges12 bronze badges




          6802 silver badges12 bronze badges












          • 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

          4192 silver badges7 bronze badges




          4192 silver badges7 bronze badges












          • 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

          7745 silver badges15 bronze badges




          7745 silver badges15 bronze badges












          • 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

















          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%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

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company