2013-02-18 180 views
0

我已經嘗試設置此功能使用此代碼Magento: get the lowest price of a grouped product by product ID?,但似乎無法得到它的工作..獲取Magento的組合產品的最低價格

這是我當前的代碼,你會我需要做的,從拿到的最低價格這個分組產品?

  <?php 
        $cat_id = 33; 
        $catagory_model = Mage::getModel('catalog/category')->load($cat_id); 
        $collection = Mage::getResourceModel('catalog/product_collection'); 
       $collection->getSelect()->order('rand()');  
        $collection->addCategoryFilter($catagory_model); 
        $collection->addAttributeToSelect(array('name','small_image', 'price')); //add product attribute to be fetched  
        if(!empty($collection)) {?> 
      <ul> 
        <?php $_columnCount = $this->getColumnCount(); ?> 
       <?php $i=0; foreach ($collection->getItems() as $_product): if($i==8){break;}?> 
       <?php if ($i++%$_columnCount==0): ?> 
       <?php endif ?> 
        <li class="span4"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product_image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(420); ?>" width="210" height="180" alt="<?php echo $_product->getName(); ?>" /></a> 

         <span class="product_name"><?php echo $_product->getName(); ?></span> 

         <span class="product_price"> 
        <?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(). sprintf('%.2f',$_product[price]) ;?> 

         <!-- WANT THE LOWEST PRICE HERE --> 

         </span> 

         <a class="product_addto" href="<?php echo $_product->getProductUrl() ?>">View Product</a> 

         </li> 
        <?php endforeach; ?> 
      </ul> 
         <?php } else { echo 'No products exists';} ?> 

在此先感謝您。對此,我真的非常感激。

回答

1
echo round($_product->getPriceModel()->getMinimalPrice($_product),2); 

HTH

+0

上的Magento 1.92 getMinimalPrice不getPriceModel對象存在 – netusco 2016-08-12 07:06:58

相關問題