1

i am updating the cart after user login for that

Error

Fatal error: Call to a member function getStoreId() on null in /opt/lampp/htdocs/instantsearch/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php on line 81

Code

foreach ($items->getAllItems() as $item) {
  $product_id = $item->getProductId();
  $customprice = 50; 
  if ($customprice > 0) 
      {  
       $item= Mage::getModel('sales/quote_item')->load($item->getId()); 
       $item->setCustomPrice($customprice);
       $item->setOriginalCustomPrice($customprice);
       $item->save(); 
      }   
    } 
1

after searching a lot i figure setProduct() was the issue

foreach ($items->getAllItems() as $item) {
      $product_id = $item->getProductId();
      $product=Mage::getModel('catalog/product')->load($product_id);
      $customprice = 50; 
      if ($customprice > 0) 
          {  
           $item= Mage::getModel('sales/quote_item')->load($item->getId()); 
           $item->setCustomPrice($customprice);
           $item->setOriginalCustomPrice($customprice);
           $item->setProduct($product);  
           $item->save(); 
          }   
        } 

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.