2

I tried to change the attribute value once we click on Delete button present in cart page :

enter image description here

config.xml :

<sales_quote_remove_item>
    <observers>
        <example_delete_from_cart>
            <class>Amasty_Example_Model_Observer</class>
            <method>DeleteFromCart</method>
        </example_delete_from_cart>
    </observers>
</sales_quote_remove_item>

app/code/local/Amasty/Example/Model - Observer.php

public function DeleteFromCart($observer) 
{ 
    $product = $observer->getEvent()->getProduct();
    Mage::getSingleton('catalog/product_action')->updateAttributes(
        array($product->getId()),
        array('cart_status' => 0),
        $storeId = 0
    );
}

Result

Fatal error: Call to a member function getId() on a non-object in line:@array($product->getId()),

2

Try below

public function DeleteFromCart($observer) 
{ 
    $product = $observer->getEvent()->getQuoteItem()->getProduct();
    Mage::getSingleton('catalog/product_action')->updateAttributes(
        array($product->getId()),
        array('cart_status' => 0),
        $storeId = 0
    );
}

Your Answer

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