A部分:$collection = Mage::getModel('catalog/product')->getCollection();
B部分:$collection = Mage::getResourceModel('catalog/product')->getCollection();
如何获得“团体价格”? 有什么办法吗?
答案 0 :(得分:2)
希望你做得很好。
根据你的问题,我们在magento中有一种方法来获得团体价格,但只有当你拥有$ product的对象时才会使用full。您可以使用getGroupPrice()检查它。下面给出了相同的例子。
<?php
$login = Mage::getSingleton( 'customer/session' )->isLoggedIn();
//Check if User is Logged In
if($login && Mage::getSingleton('customer/session') >getCustomerGroupId()==5)
{
$groupPrices = $ProductObject->getData('group_price');
$Groupprice= $groupPrices;
if (is_null($groupPrices))
{
$attribute = $ProductObject->getResource()- >getAttribute('group_price');
if ($attribute)
{
$attribute->getBackend()->afterLoad($ProductObject);
$groupPrices = $ProductObject->getData('group_price');
}
}
/* check group price exit nor not */
if (!is_null($groupPrices) || is_array($groupPrices)) {
foreach ($groupPrices as $groupPrice) {
if($groupPrice['cust_group'] == Mage::getSingleton('customer/session')->getCustomerGroupId()){
echo $Groupprice = $groupPrice['website_price'];
echo "<br/>";
echo $Groupprice=$groupPrice['cust_group'];
break;
}
}
}
/* $Groupprice is null mean group price is not exit*/
if(!is_null($Groupprice)){
//group price eixts
?>
<span class="price-label"><?php echo "Special Group Price " ?></span>
<?php
}else{
//Group price is exits.
?>
<span class="price-label"><?php echo "Now" ?></span>
<?php }
?>
<?php }
else { ?>
<span class="price-label"><?php echo "Now" ?></span>
<?php } ?>
希望这个例子将用于和等待评论!!!!