2

I want to add custom option type as image to quoteitem in checkout review page using observer which observer event is controller_action_predispatch_checkout_onepage_index and it fires when goes to checkout page.

In event call in config.xml

<controller_action_predispatch_checkout_onepage_index>
<observers>
<hackathon_presentation>
<type>singleton</type>
<class>modulename/observer</class>
<method>salesCollectBefore</method>
</hackathon_presentation>
</observers>
</controller_action_predispatch_checkout_onepage_index>

and then in my Observer.php

public function salesCollectBefore($observer)
    {    
    $quote_items = $quote->getItemsCollection();
        foreach ($quote_items as $item) {
        $customisation['upload_logo'] = "test.png";
            $additionalOptions = array(
                array(
                    'code'  => 'my_code',
                    'label' => 'Logo',
                    'print_value' =>  '<a href="'.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$customisation['upload_logo'].'">'logo'</a>',
                    'option_value' => '<a href="test">'.$customisation['upload_logo'].'</a>',
                    'value' => $customisation['upload_logo'].
                )
            );
            $item->addOption(
                array(
                     'code'  => 'additional_options',
                     'value' => serialize($additionalOptions),

                )
            );
        }
    }

It does not allow me to show as a link to download the image, It shows only the image name . I want to add the image link in order review page and it should be downlodable from the link. How can I achieve this. Can anyone help here? Plz...

  • how does the template work? – David Manners Apr 10 '15 at 7:14
  • 1
    There is no custom template for module. Default magento template works here. – SIBHI S Apr 10 '15 at 9:22
2

controller_action_predispatch_checkout_onepage_index event does not given the Current Quote object as it params.

If want current quite on this event this ,you need to call

Mage::getSingleton('checkout/session')->getQuote()

Or

Mage::getSingleton('checkout/type_onepage')->getQuote()

Code:

public function salesCollectBefore($observer)
    { 
    /* add this */   
    $quote=Mage::getSingleton('customer/session')->getQuote()
    $quote_items = $quote->getItemsCollection();
.....

So,you cannot get Currentquote object from $observer.As per as magento controller_action_predispatch_checkout_onepage_index event current.

from this event you can only get onepageController object

   Mage::dispatchEvent('controller_action_predispatch_' . $this->getFullActionName(),
            array('controller_action' => $this));

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.