When somebody adds an item to their cart on my website, there's an observer which adds a few custom options programmatically (mainly because it's much easier and it removes the dependency of having to make sure new products have these fields).

However, when somebody clicks edit on the product I need to make sure these are selected again and it uses a custom block of just HTML right now.

How can I get the values of these options on the product view page when somebody clicks edit? So I can check against the available options and select the ones that the user previously chose.



On the "configure" page you have access to the product globally with Mage::registry('current_product'). The product is prepared with all previously selected custom options, so read them from Mage::registry('current_product')->getCustomOptions() and fill out your form accordingly.


Take a look in the cart controller (Mage_Checkout_CartController) for the action configureAction this is how the default configurable products work.

The edit link in the cart is built as follows in Mage_Checkout_Block_Cart_Item_Renderer:

public function getConfigureUrl()
    return $this->getUrl(
        array('id' => $this->getItem()->getId())

And then the action will load the buying options from the quote and then set them for use in this action.

Mage::helper('catalog/product_view')->prepareAndRender($quoteItem->getProduct()->getId(), $this, $params);

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.