Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Snapshot, getPriceHtml on grouped product
 
shane242
Jr. Member
 
Total Posts:  13
Joined:  2008-09-29
 

$storeId Mage::app()->getStore()->getId();
$categoryId = (int)$this->getTitle();

if (
$categoryId 1$categoryId 95;

$resource Mage::getSingleton('core/resource');
$read $resource->getConnection('catalog_read');
$categoryProductTable $resource->getTableName('catalog/category_product');
$productEntityIntTable = (string)Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';
$eavAttributeTable $resource->getTableName('eav/attribute');

if (
$categoryId{
    $select 
$read->select()
            ->
from(array('cp'=>$categoryProductTable))
            ->
join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
            ->
joinNatural(array('ea'=>$eavAttributeTable))
            ->
where('cp.category_id=?'$categoryId)
            ->
where('pei.value=1');
            
//->where('ea.attribute_code="featured"');}
else {
    $select 
$read->select()
            ->
from(array('cp'=>$categoryProductTable))
            ->
join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
            ->
joinNatural(array('ea'=>$eavAttributeTable))
            ->
where('pei.value=1');
            
//->where('ea.attribute_code="featured"');
}
$featuredProductData 
$read->fetchAll($select);
$i=0;
$product=array();
$productid=array();
foreach (
$featuredProductData as $row{
    $productid[$i] 
$row['product_id'];                
    
$i++;
}
         
$productid
=array_unique($productid);
$limit = (int)$this->htmlEscape($this->getAnchorText());
if (
$limit 1$limit 1// fix for issues
$x 1;
foreach(
$productid as $id{
    
if ($x <= $limit{
        $_ProductInstence 
= new Mage_Catalog_Block_Product;
        
$_helper $this->helper('catalog/output');
        
$_product Mage::getModel('catalog/product')->load($id);
        if (
$_product->isSaleable()) {
            ?>
            
<li class="ckm-snapshot ckm-snapshotnum<?php echo $x; ?>">
                <
a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(117) ?>" width="117" height="117" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
                <
h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product$_product->getName() , 'name'?></a></h3>
                
<?php //echo $_this->getReviewsSummaryHtml($_product, 'short') ?>
                
<?php echo $_ProductInstence->getPriceHtml($_producttrue'-widget-new-grid'?>
                
<div class="actions">
                    <
button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart'?></span></span></button>
                </
div>
            </
li>
            
<?php
        }
        $x
++;
    
}
}

I have set-up the above code within a widget link to enable us to place a list or products to multiple places over the site pulled from a set category.

The code works perfectly for what we would like to for other then when using Grouped Product, getPriceHtml returns blank.

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
shane242
Jr. Member
 
Total Posts:  13
Joined:  2008-09-29
 

I found a work around, a slight hack but still may be helpful for others.

<?php if ($_product->isGrouped()) {
                    
// ckm.se get the group price info
                    
$_coreHelper $this->helper('core');
                    
$_taxHelper  $this->helper('tax');
                    
                    
$aProductIds $_product->getTypeInstance()->getChildrenIds($_product->getId());
                    
                    
$minprice 99999999999999;
                    
$_finalPrice '';
                    foreach (
$aProductIds as $ids{
                        
foreach ($ids as $id{
                            $aProduct 
Mage::getModel('catalog/product')->load($id);
                            if (
$minprice $aProduct->getPriceModel()->getPrice($aProduct)) {
                                $minprice 
$aProduct->getPriceModel()->getPrice($aProduct);
                                
$_finalPrice $_taxHelper->getPrice($aProduct$aProduct->getFinalPrice());
                            
}
                        }
                    }
                ?>
            
                
<div class="price-box">
                    <
class="old-price">
                        <
span id="old-price-2" class="price"><?php echo $_coreHelper->currency($_taxHelper->getPrice($_product$minprice$includingTax true), truefalse);?></span>
                    </
p>
                    <
class="special-price">
                        <
span id="product-price-2" class="price"><?php echo $_coreHelper->currency($_taxHelper->getPrice($_product$_finalPrice$includingTax true), truefalse);?></span>
                    </
p>
                   </
div>
                
<?php } else echo $_ProductInstence->getPriceHtml($_producttrue'-widget-new-grid'?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top