1

I want to be able to clear a custom column like this as soon as I login and I find that a particular SKU is in the cart.:

$quote -> setcolumn(''); 

How can I achieve this?

2 Answers 2

2

Try creating an observer for customer_login

In config.xml

 .....
<customer_login>
    <observers>
        <yourobservername>
            <type>model</type>
            <class>yourmodule/path_to_class</class>
            <method>customerLogin</method>
        </yourobservername>
    </observers>
</customer_login>

In Observer.php

class YourCompany_YourModule_Model_Observer
{
    public function customerLogin($observer)
    {
        //$customer = $observer->getCustomer();
       $updateCart = false
       $quote = Mage::getSingleton('checkout/session')->getQuote();
       $cartItems = $quote->getAllVisibleItems();
       foreach ($cartItems as $item) {
           if($sku == $item->getSku()){
              $item->setcolumn('');
              $updateCart = true;
           }
       }

       if(updateCart){
           $quote$quote->getCart()->save();
       }

    }
}

See Magento - remove one quantity from cart

0

Try this.

$_NULL = new Zend_Db_Expr("NULL");
$quote -> setcolumn($_NULL);
2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. Commented Feb 12, 2015 at 4:29
  • What are you supposed to do with this answer? And who ever down voted, can I know the reason?
    – Sukeshini
    Commented Feb 12, 2015 at 10:53

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.