Is it possible to set product special price for current session? because i have to set product special price if my custom condition is satisfied?is it possible?
2 Answers
If you have a look at Mage_Catalog_Model_Product
class you can find a method
/**
* Returns special price
*
* @return float
*/
public function getSpecialPrice()
{
return $this->_getData('special_price');
}
You can easily rewrite this method and add you condition there to set special price based on your condition. It could be something like this.
/**
* Returns special price
*
* @return float
*/
public function getSpecialPrice()
{
if ($yourCondition) {
if (!isset($this->_getData('mycustom_special_price'))) {
$this->_setData('mycustom_special_price', $customerPrice);
}
return $this->_getData('mycustom_special_price');
} else {
return parent::getSpecialPrice();
}
}
-
i have to set special price for certain coupon code if some of my coupon is applied then it apply for special price otherwise not Commented Dec 31, 2013 at 6:38
-
If you have coupon codes then you can easily set the condition in shopping cart price rule (default Magento feature). I don't think I am following your question here, now. Commented Dec 31, 2013 at 6:45
-
ya i know that but due to some condition i don't have to apply shopping cart rule for that Commented Dec 31, 2013 at 6:51
you can set the session using set, getting value using get and unset session using uns.
Mage::getSingleton(‘core/session’)->setMySessionVariable(‘MyValue’);
$myValue = Mage::getSingleton(‘core/session’)->getMySessionVariable();
echo $myValue;
Mage::getSingleton(‘core/session’)->unsMySessionVariable();