Skip to content

Instantly share code, notes, and snippets.

@b3k
Created March 14, 2014 10:22
Show Gist options
  • Save b3k/9545307 to your computer and use it in GitHub Desktop.
Save b3k/9545307 to your computer and use it in GitHub Desktop.
Get cheapest active product from given category.
<?php
class Product {
public function getCheapestProduct() {
$data = Mage::getModel("catalog/product")->getCollection()
->addAttributeToSelect(Mage::getSingleton("catalog/config")->getProductAttributes())
->addAttributeToFilter('offer', Mage_MultiVendor_Model_Offer::STATE_ACTIVE)
->addCategoryFilter($this->getCategory())
->setPage(1, 1)
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->load()
->getFirstItem();
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment