0

I have an observer and would like to get the selected custom options array.

I have found the two elements I require in:

app/design/frontend/MY-THEME/default/template/checkout/cart/item/default.phtml

Which are:

$_item = $this->getItem();
$_options = $this->getOptionList();

I just don't know how to get them in an observer i.e. what else I have to call.

  • what event are you observing? – Marius Sep 8 '15 at 15:12
2

I assume your observer method looks something like this:

public function doSomething($observer)
{
    ...
}

If so, you can get the item like this:

$_item = $observer->getQuoteItem();

and you can get the options like this:

$options = Mage::helper('catalog/product_configuration')->getCustomOptions($_item); //where $_item is the result of the previous line.
  • Thanks, but I need to call specifically 'getOptionList();' which unfortunately is not working. Do you have any suggestions? – windywah Sep 8 '15 at 15:35
  • If I use: $options = Mage::helper('catalog/product_configuration')->getOptionList($_item); I get: Call to undefined method MageWorx_CustomOptions_Helper_Product_Configuration::getOptionList() – windywah Sep 8 '15 at 15:40
  • The method name is getCustomOptions not getOptionList – Marius Sep 8 '15 at 16:14
  • The method I require is getoptionlist() which works fine in: app/design/frontend/MY-THEME/default/template/checkout/cart/item/default.phtml I just need to know how to use it in an observer. Thanks! – windywah Sep 8 '15 at 16:57
  • You cannot use the exact method because that one is available only in that block. I gave you an alternative. The method in the template you mentioned is basically a wrapper for what I suggested. – Marius Sep 8 '15 at 17:18

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.