0

Need to add some custom option to product after adding this product to cart. I use this observer:

  <checkout_cart_add_product_complete>
   <observers>
   <test_chooser_observer>
    <type>singleton</type>
    <class>test_chooser_model_observer</class>
    <method>addAttributes</method>
   </test_chooser_observer>
    </observers>
  </checkout_cart_add_product_complete>

And this code:

public function addAttributes($observer)
            {
               $event = $observer->getEvent();
                    $quoteItem = $event->getQuoteItem();
             $additionalOptions[] = array(
                                'label' => 'Test',
                                'value' => 'Test',
                            );
            $quoteItem->getProduct()->addCustomOption('additional_options', serialize($additionalOptions));
                    return $this;

            }

But i see blank page. I use answers for earliest version of magento, but it seems they don't work in 1.8.1

Keyur Shah
  • 11,043
  • 4
  • 29
  • 48
kafaya
  • 101
  • 2
  • 13

1 Answers1

1

Try changing your class to: Test_Chooser_Model_Observer like this:

<class>Test_Chooser_Model_Observer</class>
seanbreeden
  • 6,104
  • 5
  • 36
  • 45
  • Did'nt help. If i put var_dump('111111'); on this method, i see this '111111' on blank page, so method is work. Code foir adding custom options is not working. – kafaya May 13 '14 at 06:01
  • Have you seen this answer by Vinai? http://stackoverflow.com/questions/9412074/magento-quote-order-product-item-attribute-based-on-user-input/9496266#9496266 – seanbreeden May 13 '14 at 12:33