Magento 单产品(product)或者当前类别(category)最大和最小价格 Min Max Product Price in a Category

Magento 单产品(product)或者当前类别(category)最大和最小价格 Min Max Product Price in a Category

当前类别最大最小价格:

$minPrice = Mage::getModel('catalog/product')->getCollection()
               ->addStoreFilter()
               ->addAttributeToSelect('price')
               ->addAttributeToSort('price', 'ASC')->getFirstItem()->getMinimalPrice()*1;

$maxPrice = Mage::getModel('catalog/product')->getCollection()
               ->addStoreFilter()
               ->addAttributeToSelect('price')
               ->addAttributeToSort('price', 'DESC')->getFirstItem()->getMinimalPrice()*1;

当前产品最大最小价格:

$categoryModel = Mage::getModel('catalog/category')->load($id); // Replace with Id of Cat

$productColl = Mage::getModel('catalog/product')->getCollection()
->addCategoryFilter($categoryModel)
->addAttributeToSort('price', 'asc')
->setPageSize(1)
->load();

$lowestProductPrice = $productColl->getFirstItem()->getPrice();

$productColh = Mage::getModel('catalog/product')->getCollection()
->addCategoryFilter($categoryModel)
->addAttributeToSort('price', 'desc')
->setPageSize(1)
->load();

$highestProductPrice = $productColh->getFirstItem()->getPrice();

发表评论

发表评论

*

沙发空缺中,还不快抢~