1

This is my config code.

<catalog_block_product_list_collection>
            <observers>
                <smashingmagazine_logproductupdate>
                    <class>smashingmagazine_logproductupdate/observer</class>
                    <method>listingchange</method>
                    <type>singleton</type>
                </smashingmagazine_logproductupdate>
            </observers>
        </catalog_block_product_list_collection>

This is my function.

public function listingchange(Varien_Event_Observer $observer)
{
    $collection = $observer->getEvent()->getCollection();

    foreach ($collection as $product)
    {
       $product->setPrice( 1500 );
    }

}

price get in list.phtml file price code is.

<?php echo $this->getPriceHtml($_product, true) ?>

The setPrice() is not work. getPrice() function is work fine.

but setPrice() is not work.

please help. thank's

2 Answers 2

3

Use $product->setFinalPrice(1500); if you want to set price immediately. If you change only price using setPrice(), than magento will calculate price via its own logic, see Mage_catalog_Model_Product:

public function getFinalPrice($qty=null)
    {
        $price = $this->_getData('final_price');
        if ($price !== null) {
            return $price;
        }
        return $this->getPriceModel()->getFinalPrice($qty, $this);
    }
3
  • hey this is working but the original price is set as 'As low as : $45' below price. please help. Aug 8, 2014 at 13:09
  • This will be a long history, try to understand Magento product price calculation process
    – mageUz
    Aug 8, 2014 at 13:11
  • hey how can i changed price on cart view page please help. Aug 8, 2014 at 13:40
1

ISSUE WITH you observer code

Try this

public function listingchange(Varien_Event_Observer $observer)
{
    $collection = $observer->getEvent()->getCollection();


        foreach ($collection->getItems() as $_item ) {
                    $_item->setPrice( 1500 );
        }

        return $this;

}
1
  • This is not working. Aug 8, 2014 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.