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

          Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

          Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

          Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020