/** * @param null $product * @return mixed */ public function getPriceByCatalogRules($product = null) { if (is_null($product)) { $product = $this->getProduct(); } if (!$this->getConfigVar('apply_catalog_price_rules', 'columns')) { // Commented to avoid loops: return $this->getPrice($product); return $product->getPrice(); } if (!isset($this->_cache_price_by_catalog_rules[$product->getId()])) { $this->_cache_price_by_catalog_rules[$product->getId()] = Mage_Catalog_Model_Product_Type_Price::calculatePrice($product->getPrice(), false, false, false, false, $this->getWebsiteId(), Mage::getStoreConfig('customer/create_account/default_group', $this->getStoreId()), $product->getId()); if ($this->_cache_price_by_catalog_rules[$product->getId()] <= 0) { // Commented to avoid loops: $this->_cache_price_by_catalog_rules[$product->getId()] = $this->getPrice($product); $this->_cache_price_by_catalog_rules[$product->getId()] = $product->getPrice(); } } return $this->_cache_price_by_catalog_rules[$product->getId()]; }
public function testCalculatePrice() { $this->assertEquals(10, Mage_Catalog_Model_Product_Type_Price::calculatePrice(10, 8, '1970-12-12 23:59:59', '1971-01-01 01:01:01')); $this->assertEquals(8, Mage_Catalog_Model_Product_Type_Price::calculatePrice(10, 8, '1970-12-12 23:59:59', '2034-01-01 01:01:01')); }
/** * @param null $product * @return mixed */ public function getPriceByCatalogRules($product = null) { if (is_null($product)) { $product = $this->getProduct(); } if (!$this->getConfigVar('apply_catalog_price_rules', 'columns')) { // Commented to avoid loops: return $this->getPrice($product); return $product->getPrice(); } if (!isset($this->_cache_price_by_catalog_rules[$product->getId()])) { $this->_cache_price_by_catalog_rules[$product->getId()] = Mage_Catalog_Model_Product_Type_Price::calculatePrice($product->getPrice(), false, false, false, false, $this->getWebsiteId(), Mage_Customer_Model_Group::NOT_LOGGED_IN_ID, $product->getId()); if ($this->_cache_price_by_catalog_rules[$product->getId()] <= 0) { // Commented to avoid loops: $this->_cache_price_by_catalog_rules[$product->getId()] = $this->getPrice($product); $this->_cache_price_by_catalog_rules[$product->getId()] = $product->getPrice(); } } return $this->_cache_price_by_catalog_rules[$product->getId()]; }