Exemplo n.º 1
0
 /**
  * @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()];
 }
Exemplo n.º 2
0
 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'));
 }
Exemplo n.º 3
0
 /**
  * @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()];
 }