Show Grouped product price in catalog view as sum of associated products in grouped product
In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.
For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".
In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".
It should be displayed as a sum which in this case equal to "$360".
I hope someone could help me to find the solution.
magento2 price catalog-price-rules grouped-products
add a comment |
In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.
For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".
In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".
It should be displayed as a sum which in this case equal to "$360".
I hope someone could help me to find the solution.
magento2 price catalog-price-rules grouped-products
1
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04
add a comment |
In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.
For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".
In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".
It should be displayed as a sum which in this case equal to "$360".
I hope someone could help me to find the solution.
magento2 price catalog-price-rules grouped-products
In my magento store majority of products are "grouped products". Right now when you go in category you can see the label under the product image says "Price starting at" and the lower price of two associated products.
For example if one associated product cost $150 and the second $210, so the price in category view will be displayed as "Price starting at - $150".
In my case I want that the grouped product price would be displayed as the sum of two associated products without any labels like "Price starting at".
It should be displayed as a sum which in this case equal to "$360".
I hope someone could help me to find the solution.
magento2 price catalog-price-rules grouped-products
magento2 price catalog-price-rules grouped-products
asked Dec 19 '16 at 13:28
Tautvydas BanysTautvydas Banys
64
64
1
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04
add a comment |
1
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04
1
1
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04
add a comment |
2 Answers
2
active
oldest
votes
I just had the same requirement. For a quick solution copy theme file
Magento_GroupedProducttemplatesproductpricefinal_price.phtml
to your custom theme and sum prices in template with
<?php
/*
* Show combined price instead of minimal price for grouped products.
*/
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}
?>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>
Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
add a comment |
I've refactored the code of @skymeissner:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);
if ($allProducts) {
$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}
?>
<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>
add a 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%2f150951%2fshow-grouped-product-price-in-catalog-view-as-sum-of-associated-products-in-grou%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I just had the same requirement. For a quick solution copy theme file
Magento_GroupedProducttemplatesproductpricefinal_price.phtml
to your custom theme and sum prices in template with
<?php
/*
* Show combined price instead of minimal price for grouped products.
*/
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}
?>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>
Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
add a comment |
I just had the same requirement. For a quick solution copy theme file
Magento_GroupedProducttemplatesproductpricefinal_price.phtml
to your custom theme and sum prices in template with
<?php
/*
* Show combined price instead of minimal price for grouped products.
*/
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}
?>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>
Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
add a comment |
I just had the same requirement. For a quick solution copy theme file
Magento_GroupedProducttemplatesproductpricefinal_price.phtml
to your custom theme and sum prices in template with
<?php
/*
* Show combined price instead of minimal price for grouped products.
*/
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}
?>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>
Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!
I just had the same requirement. For a quick solution copy theme file
Magento_GroupedProducttemplatesproductpricefinal_price.phtml
to your custom theme and sum prices in template with
<?php
/*
* Show combined price instead of minimal price for grouped products.
*/
$products = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceForAll = 0;
foreach ($products as $product) {
$priceForAll += $product->getPrice();
}
?>
<div class="price-box price-final_price" data-role="priceBox" data-product-id="284">
<span class="price-container price-final_price tax weee">
<span id="product-price-284" data-price-amount="<?php echo $priceForAll?>" data-price-type="finalPrice" class="price-wrapper ">
<span class="price"><?php echo number_format($priceForAll,2,',','.')?> €</span>
</span>
</span>
</div>
Please note that the final price formatting in html is a quick hack and just fits my requirements. A more felxible solution taking into account magento's price formatting features is welcome!
edited Jan 9 '17 at 8:25
answered Dec 30 '16 at 16:02
skymeissnerskymeissner
13810
13810
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
add a comment |
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Can you show all code in final_price.phtml file?
– Tautvydas Banys
Jan 6 '17 at 19:22
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
Edited the code snippet.
– skymeissner
Jan 9 '17 at 8:25
add a comment |
I've refactored the code of @skymeissner:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);
if ($allProducts) {
$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}
?>
<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>
add a comment |
I've refactored the code of @skymeissner:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);
if ($allProducts) {
$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}
?>
<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>
add a comment |
I've refactored the code of @skymeissner:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);
if ($allProducts) {
$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}
?>
<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>
I've refactored the code of @skymeissner:
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/**
* Template for displaying grouped product price
*/
?>
<?php
$allProducts = $block->getSaleableItem()->getTypeInstance()->getAssociatedProducts($block->getSaleableItem());
$priceHelper = $this->helper(MagentoFrameworkPricingHelperData::class);
if ($allProducts) {
$priceForAll = 0;
foreach ($allProducts as $product) {
$priceForAll += $product->getPrice();
}
}
?>
<div class="price-box" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if ($priceForAll > 0 && MagentoFrameworkPricingRender::ZONE_ITEM_VIEW != $block->getZone()): ?>
<p class="grouped-price">
<span class="price-label">
<?= /* @escapeNotVerified */ __('Starting at') ?>
</span>
<span class="price">
<?= $formattedPrice = $priceHelper->currency($priceForAll, true, false); ?>
</span>
</p>
<?php endif ?>
</div>
answered 11 mins ago
Stevie-Ray HartogStevie-Ray Hartog
134
134
add a comment |
add a 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%2f150951%2fshow-grouped-product-price-in-catalog-view-as-sum-of-associated-products-in-grou%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
1
For your requirement you need to customized magento functionality.
– Dhiren Vasoya
Dec 19 '16 at 13:32
Maybe you know what exactly?
– Tautvydas Banys
Dec 20 '16 at 0:56
Have you try any thing for this?
– Dhiren Vasoya
Dec 20 '16 at 3:04