0

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?

  • you can create new session variable. when your work finish then you can unset that variable – Keyul Shah Dec 31 '13 at 5:28
  • @keyul i have to set special price using only for current session not for whole product – Keyur Shah Dec 31 '13 at 6:07
1

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 – Keyur Shah Dec 31 '13 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. – Subesh Pokhrel Dec 31 '13 at 6:45
  • ya i know that but due to some condition i don't have to apply shopping cart rule for that – Keyur Shah Dec 31 '13 at 6:51
2

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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