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;
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
add a comment |
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
add a comment |
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
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
product checkout category cart magento2.3
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
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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');
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
add a comment |
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 :
- In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.
- In Above code "3" is the category id, Change the category id as per your requirement.
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
add a comment |
I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom
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;
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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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');
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
add a comment |
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');
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
add a comment |
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');
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');
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
add a comment |
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
add a comment |
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 :
- In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.
- In Above code "3" is the category id, Change the category id as per your requirement.
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
add a comment |
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 :
- In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.
- In Above code "3" is the category id, Change the category id as per your requirement.
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
add a comment |
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 :
- In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.
- In Above code "3" is the category id, Change the category id as per your requirement.
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 :
- In Above code we have reused the default product list template, you can Create the separate template for that and modify the code accordingly.
- In Above code "3" is the category id, Change the category id as per your requirement.
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
add a comment |
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
add a comment |
I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom
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;
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
|
show 1 more comment
I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom
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;
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
|
show 1 more comment
I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom
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;
I suggest you create a Wiget to add product list with a category on Shopping Cart this option without using any custom
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;
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
|
show 1 more comment
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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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