Frage

I've got an observer which changes the prices of products in the product list and the product view. To realize that i'm using the catalogProductLoadAfter and the catalogProductCollectionLoadAfter events.

public function catalogProductLoadAfter( $observer )
{
        $product    = $observer->getEvent()->getProduct();
        $product->setPrice( 123.00 );
}


public function catalogProductCollectionLoadAfter( $observer )
{
        $collection = $observer->getEvent()->getCollection();
        foreach ($collection as $product)
        {
               $product->setPrice(123.00); // doesn't work
        }
}

The catalogProductLoadAfter $product->setPrice works fine, but in catalogProductCollectionLoadAfter it does nothing... no error, no changing, nothing. What did i wrong Oo ?! Is there any magic i've to use or is that a magento bug ?

I've worked for a company which had such an observer too and there only works the catalogProductLoadAfter setPrice too and not the catalogProductCollectionLoadAfter setPrice.

I'm using the Trego Design and the Simple Configurable Product Plugin which has an AJAX product updater.. Is it possible that there are conflicts, maybe the trego plugins or the SCP Plugin overrides the prices too ?

//Edit: i searched for any setPrice uses, nothing found which can create conflicts.. no extern actions from other modules

Thanks for any help.

Greetings

War es hilfreich?

Lösung

Try this

public function catalogProductCollectionLoadAfter( $observer )
{
        $collection = $observer->getEvent()->getCollection();
        foreach ($collection as $product)
        {
               $product->setData('my_price','123.00');
        }
}

You can retrieve the price value like below:

$product->getMyPrice();

OR

$product->getData('my_price');
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top