Magento:按产品ID获取分组产品的最低价格?
我有一段代码可以返回包括价格在内的产品数据。然而,对于分组产品,它没有给出价格。
有没有办法获取分组产品的ID并获得该组的最低价格?
这是我的代码:
<?php
$id_array = strip_tags($this->getLayout()->createBlock('cms/block')->setBlockId('homepage-newest-product')->toHtml());
$product_id = explode(',',$id_array);
foreach ($product_id as $id):
$productDetails = Mage::getModel('catalog/product')->load($id)->getData();
//var_dump($productDetails);
?>
<li class="a-center span-3">
<a href="<?php echo $this->getBaseUrl() . $productDetails['url_path']; ?>"><img src="<?php echo $media_url . 'catalog/product' . $productDetails['thumbnail']; ?>" width="80" height="80"/></a>
<a href="<?php echo $this->getBaseUrl() . $productDetails['url_path']; ?>" class="clearfix"><?php echo $productDetails['name']; ?></a>
<?php if($productDetails['price']): ?>
<span>
<?php echo $_coreHelper->currency($productDetails['price'],true,false) ?>
</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
最好有一个函数,它接受分组 ID 并查找该组的最低价格,然后返回价格。
I have a piece of code that returns product data including a price. However for a grouped product it doesn't give the price.
Is there a way to take the ID of the grouped product and get the lowest price of the group?
Here is my code:
<?php
$id_array = strip_tags($this->getLayout()->createBlock('cms/block')->setBlockId('homepage-newest-product')->toHtml());
$product_id = explode(',',$id_array);
foreach ($product_id as $id):
$productDetails = Mage::getModel('catalog/product')->load($id)->getData();
//var_dump($productDetails);
?>
<li class="a-center span-3">
<a href="<?php echo $this->getBaseUrl() . $productDetails['url_path']; ?>"><img src="<?php echo $media_url . 'catalog/product' . $productDetails['thumbnail']; ?>" width="80" height="80"/></a>
<a href="<?php echo $this->getBaseUrl() . $productDetails['url_path']; ?>" class="clearfix"><?php echo $productDetails['name']; ?></a>
<?php if($productDetails['price']): ?>
<span>
<?php echo $_coreHelper->currency($productDetails['price'],true,false) ?>
</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
Preferebly I'd have a function that takes the grouped ID and looks up the lowest price of the group, then returns the price.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
方法如下:
您也可以根据活动准备价格,但此问题是获得最低团价的最简单方法。
The method looks like below:
Also you can prepare price with events, but this issue is the simplest way to get lowest group price.