Problem: in the cart is a product set together from selected options. Now I want to edit one of those products.

Question: how do I get the same option values to the configure page? The page that has this path is checkout/cart/configure/id/1/

Where does Magento has to take the needed informations from?

PS. I use a Custom Theme!

The information is pulled from the quote object that is persisted in the database. The integer on the end of the checkout/cart/configure/id/123 is a reference to the quote item ID from the sales_flat_quote_item table.

In short, when you hit the configure page, it fetches the item and looks up the configuration option selections in order to pre-populate the form with them.

You could access this information via...

/* @var $cart Mage_Checkout_Model_Cart */
$cart = Mage::helper( 'checkout/cart' )->getCart();

/* @var $item Mage_Sales_Model_Quote_Item */
$item = $cart->getQuote()->getItemById( $id );

There's a method available to Mage_Sales_Model_Quote_Item called getBuyRequest that returns the configured options.

/**
 * Returns formatted buy request - object, holding request received from
 * product view page with keys and options for configured product
 *
 * @return Varien_Object
 */
public function getBuyRequest()
{
    $option = $this->getOptionByCode('info_buyRequest');
    $buyRequest = new Varien_Object($option ? unserialize($option->getValue()) : null);

    // Overwrite standard buy request qty, because item qty could have changed since adding to quote
    $buyRequest->setOriginalQty($buyRequest->getQty())
        ->setQty($this->getQty() * 1);

    return $buyRequest;
}

This is a good starting spot.

  • Thanks for your help! Where do I have to use these codes? On what page of the template? Thanks – user2136749 Dec 20 '13 at 16:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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