Created
March 14, 2014 10:22
-
-
Save b3k/9545307 to your computer and use it in GitHub Desktop.
Get cheapest active product from given category.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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