我尝试使用此代码Magento 进行设置:按产品 ID 获取分组产品的最低价格?但似乎无法让它工作..
这是我当前的代码,我需要做什么才能从这个分组产品中获得最低价格?
<?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';} ?>
先感谢您。对此,我真的非常感激。