How to show a category's products in shopping cartDoes not show categories or products in homepageHow to show specific category products in cart page?How to display related products on the cart page (checkout)?How can I show the same product multiple times in the shopping cart?Getting category's custom attribute valueHow to determine upsell products in shopping cartShopping cart empties abruptly - cookies not persistingShow last 5 purchase order products details in shopping cart page (like last minuts shopping)How to check shopping cart empty magento 2?custom table data show on shopping cart pageShopping Cart Rules for Mixed ProductsShopping Cart Thumbnails not showing
How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?
How can I detect if I'm in a subshell?
How to address players struggling with simple controls?
Credit card validation in C
What is "dot" sign in •NO?
Can you place a web spell on a surface you cannot see?
Do battery electrons only move if there is a positive terminal at the end of the wire?
Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)
Does knowing the surface area of all faces uniquely determine a tetrahedron?
Is a sequel allowed to start before the end of the first book?
How to avoid offending original culture when making conculture inspired from original
Is the infant mortality rate among African-American babies in Youngstown, Ohio greater than that of babies in Iran?
How to sort human readable size
Explicit song lyrics checker
You may find me... puzzling
Who was the youngest Executive Producer?
Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?
A medieval book with a redhead girl as a main character who allies with vampires and werewolves against scientific opposition
How "fast" do astronomical events occur?
Why we can't jump without bending our knees?
Is it possible to use just one shared folder for log shipping?
I have found ports on my Samsung smart tv running a display service. What can I do with it?
Right indicator flash-frequency has increased and rear-right bulb is out
Harmonic Series Phase Difference?
How to show a category's products in shopping cart
Does not show categories or products in homepageHow to show specific category products in cart page?How to display related products on the cart page (checkout)?How can I show the same product multiple times in the shopping cart?Getting category's custom attribute valueHow to determine upsell products in shopping cartShopping cart empties abruptly - cookies not persistingShow last 5 purchase order products details in shopping cart page (like last minuts shopping)How to check shopping cart empty magento 2?custom table data show on shopping cart pageShopping Cart Rules for Mixed ProductsShopping Cart Thumbnails not showing
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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
New contributor
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
New contributor
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
New contributor
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
New contributor
New contributor
edited yesterday
Aasim Goriya
3,19211141
3,19211141
New contributor
asked Jun 10 at 4:26
wltprgmwltprgm
214
214
New contributor
New contributor
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
);
);
wltprgm is a new contributor. Be nice, and check out our Code of Conduct.
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
680212
680212
2 exception(s): Exception #0 (MagentoFrameworkExceptionLocalizedException): Invalid block type: catalog/product_list Exception #1 (ReflectionException): Class catalog/product_list does not exist
– wltprgm
Jun 10 at 7:17
Check updated answer.
– Mohit chauhan
Jun 10 at 7:21
Same error, Block doesn't allow type and category_id, devdocs.magento.com/guides/v2.3/frontend-dev-guide/layouts/…
– wltprgm
Jun 10 at 7:37
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
40927
40927
Hi there, I actually wrote a similar code to yours. But I still tried your code just in case. I still get the same error. Class catalog/product_list does not exist AND Invalid block type: catalog/product_list
– wltprgm
Jun 10 at 8:22
I think there is no catalog/product_list in layout folder, that's why it's causing this issue. But I am not sure.
– wltprgm
Jun 10 at 8:25
An answer for another question said that I have to whitelist catalog/product_list, but there is no such settings in backend magento.stackexchange.com/a/98084/80197
– wltprgm
Jun 10 at 8:27
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
774515
774515
I modified my question, I need to solve this programmatically, in order to achieve certain feature
– wltprgm
Jun 12 at 2:10
Updated answer. You need to define Magento Version you have used.
– HoangHieu
Jun 12 at 2:52
What does this sentence means? "If you need to customer order product collection by own."
– wltprgm
Jun 12 at 3:39
How do I create new block? in what folder? app/code, app/design?
– wltprgm
Jun 12 at 3:39
You need to learn how to create block Magento 2 first.
– HoangHieu
Jun 12 at 4:07
|
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
wltprgm is a new contributor. Be nice, and check out our Code of Conduct.
wltprgm is a new contributor. Be nice, and check out our Code of Conduct.
wltprgm is a new contributor. Be nice, and check out our Code of Conduct.
wltprgm is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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