How to show all price of a grouped product in any list ? 

Please LogIn to Reply!

Post By: admin | 26-01-2012 06:35 Reply

 

Hi,
I know this topic has already been created (with no answers), I’m sorry to create a new one but when I tried to answer the other one, it didn’t seem to work =/
Anyway the issue is that, when you get a list (search list, related products list, etc), if there’s a grouped product in it, its price is displayed like “Starting to : [minimalPrice] “. I would like all the prices of a grouped product to be displayed in any list, so far I know the new code has to be put in appdesignfrontendbasedefaulttemplatecatalogproductprice.phtml, just after this code (about line 385) :

<?php
    $_exclTax 
$_taxHelper->getPrice($_product$_minimalPriceValue$includingTax null);
    
$_inclTax $_taxHelper->getPrice($_product$_minimalPriceValue$includingTax true);
    
?>
    <?php 
if ($this->getDisplayMinimalPrice() && $_minimalPriceValue): ?>
        
<div class="price-box">
            <
class="minimal-price">
                <
span class="price-label"><?php echo $this->__('Starting at:'?></span>

appdesignfrontendbasedefaulttemplatecatalogproductviewtypegrouped.phtml is the page of a grouped product that contains all the prices this time. So I used the code of this page to put it in price.phtml, like this :

$_associatedProducts $this->getAssociatedProducts();
    
$_hasAssociatedProducts count($_associatedProducts) > 0;
<?php if ($_hasAssociatedProducts): ?>
                <?php 
foreach ($_associatedProducts as $_item): ?>
                    <?php $_finalPriceInclTax 
$this->helper('tax')->getPrice($_item$_item->getFinalPrice(), true?>
                        <?php 
if ($this->getCanShowProductPrice($_item)): ?>
                            <?php 
echo $this->getPriceHtml($_itemtrue?>
                            <?php 
echo $this->getTierPriceHtml($_item?>
                        <?php 
else: ?>
                            
<class="availability out-of-stock"><span><?php echo $this->__('Out of stock'?></span></p>
                        
<?php endif; ?>
                    
</tr>
                
<?php endforeach; ?>
                <?php 
else: ?>
                   
<tr>
                       <
td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.'?></td>
                   </
tr>
                
<?php endif; ?>
This has been added, right now I don’t care of the <tr><td>, etc, because magento does not consider that there are associated products, that’s my issue, then it enters in the “else” instaed of the “if”, and in the frontend I have this: “Starting at : No options of this product are available. 10.00 €”
I’m using Magento 1.4.2.0.
This is what I’m attempting to do : grouped products in list

English is not my native language, so if there is anything which is not understood, just ask me.
I really hope someone will be able to help me.
Thanks

 

The issue seems to come from the function getAssociatedProducts, which only works in the page grouped.phtml. When using it anywhere else, the value returned is null, in grouped.html, it is not.
This issue comes from the classes and their extends, I tried to extend the class used in my page (where the function getAssociatedProducts doesn’t work) to the class used in the page where it works (grouped.phtml), which one’s one of the mother class is the one I changed the extend.
Wow this may be disturbing xD I’ll give you an exemple if needed.

Thanks

 

Hi. Sorry, I know this is an older thread but just in case it still needs answering or if this might help anyone else…

Firstly you need to replace the $_associatedProducts definition from:

$_associatedProducts $this->getAssociatedProducts();

to:

$_associatedProducts $_product->getTypeInstance(true)->getAssociatedProducts($_product);

The rest should then become clear. To list each product in the group with its price and an ‘Add to cart’ button the following code should do the job:

<?php $_associatedProducts $_product->getTypeInstance(true)->getAssociatedProducts($_product); ?>
<?php $_hasAssociatedProducts 
count($_associatedProducts) > 0?>                
<?php 
if ($_hasAssociatedProducts): ?>
    
<table>
    
<?php foreach ($_associatedProducts as $_item): ?>
        <?php $_finalPriceInclTax 
$this->helper('tax')->getPrice($_item$_item->getFinalPrice(), true?>
        
<tr>
            <
td><?php echo $this->htmlEscape($_item->getName()) ?></td>
            <
td>
                
<?php echo $_coreHelper->currency($_finalPriceInclTaxtruefalse)?>
            
</td>           
        </
tr>
        <
tr>
            <
td>
                    
<?php if($_item->isSaleable()): ?>
                        
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart'?></span></span></button></p>
                    
<?php else: ?>
                        
<class="availability out-of-stock"><span><?php echo $this->__('Out of stock'?></span></p>
                    
<?php endif; ?>
            
            
</td>
        </
tr>
    
<?php endforeach; ?>
    
</table>
<?php endif; ?>

Hope that helps.

`Reply Or Comment!
Please LogIn to Reply!