I added a product into the cart and tried to map customer id, email to that quote using the code below

$product_id = 123; 
$qty        = 1; 
$product    = Mage::getModel('catalog/product')->load($product_id);
$cart       = Mage::getModel('checkout/cart'); 

$superAttributeArray = array('151' => '3');
$params = array(
    'product' => $product_id,
    'qty'     => $qty,
    'super_attribute' => $superAttributeArray
$cart->addProduct($product, $params);

$currenQuoteId = Mage::getSingleton('checkout/session')->getQuoteId();
$store = Mage::getSingleton('core/store')->load(Mage::app()->getStore()->getId());
$quote = Mage::getModel('sales/quote')->setStore($store)->load($currenQuoteId);

When I try to set customerid,email,fname,lname am getting the error

"Mage registry key "controller" already exists".

Can anyone help me in fixing this issue?

  • 1
    Could you post the full stack trace for that error from exceptions.log? Something is calling Mage::register('controller', ...), but it's not clear what from your code. – Ryan Hoerr Aug 19 '15 at 15:09
  • Take a look at stackoverflow.com/questions/9737069/… – Renon Stewart Aug 19 '15 at 16:08
  • Is there a reason for manually loading the quote and not using Mage::getSingleton('checkout/session')->getQuote();? – Renon Stewart Aug 19 '15 at 16:12

Due to setStore it will throw error.remove setstore. load your quote using below code

| improve this answer | |

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.