I’m kind of stuck with a module I’m currently writing.
The client wants to use a third party pricing supply (web service) for existing customers (when they’re logged in). Currently I’ve got the pricing for the product page overloaded and for general collections but the one I’m struggling to get to work is the layered navigation pricing.
The minimal price and final price are calculated in the query itself which means I can’t simply modify it.
I’ve tracked it all back to the prepareProductCollection() method in the Mage_Catalog_Model_Layer model and ideally, if I could simply loop through the collection, get the correct pricing for each product and then write them back to the collection it ‘should’ do what I need it to. However, If I do this in the way that you’d normally do it in an observer (there are no events dispatched around this method from what I can tell) then it doesn’t update the collection how I’d expect.
Original Method:
public function prepareProductCollection($collection)
{
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addUrlRewrite($this->getCurrentCategory()->getId());
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
return $this;
}
Modified Method that currently isn’t working quite right (explicitly setting the prices for now):
public function prepareProductCollection($collection)
{
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addUrlRewrite($this->getCurrentCategory()->getId());
foreach($collection as $product) {
$product->setMinimalPrice("13.5");
$product->setFinalPrice("13.5");
$product->setMinPrice("13.5");
}
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
return $this;
}
Any ideas or alternative solutions to carry out the pricing change globally in one place would be greatly appreciated.