Alex Hadley
Alex Hadley

Reputation: 2125

Magento ignore special price for certain stores/different getFinalPrice on list and view

I'm looking to have special prices ignored for some stores, so far I've changed /Catalog/Model/Product/Type/Price.php by adding extra conditions to:

public static function calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $store = null)
{       
    if (!is_null($specialPrice) && $specialPrice != false && (extra conditions using store code)) {
        if (Mage::app()->getLocale()->isStoreDateInInterval($store, $specialPriceFrom, $specialPriceTo)) {
            $finalPrice     = min($finalPrice, $specialPrice);
        }
    }
    return $finalPrice;
}

And this works great almost everywhere. However on list view, and search results, where I've called

$this->helper('core')->currency($_product->getFinalPrice(),true,true)

It seems to be using a different method, and I can't track it down - any thoughts?

UPDATE: The very same method called on the view.phtml page works correctly, so it is something to do with the differing methods called on each page.

ALSO: I know I could just use something other than getFinalPrice on list, since it works in the cart/item page already, but I need it to not break things like sort by price, and price filters.

Upvotes: 0

Views: 1485

Answers (1)

Alex Hadley
Alex Hadley

Reputation: 2125

To show the price as required on the list page too, I needed to change Mage/Catalog/Model/Product.php as well.

public function getFinalPrice($qty=null)
{

    if (same store code conditions)
        $price = $this->_getData('final_price');
    else $price = $this->getPrice();
    if ($price !== null) {
        return $price;
    }
    return $this->getPriceModel()->getFinalPrice($qty, $this);
}

Upvotes: 1

Related Questions