Skip to main content
added 8 characters in body
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

/app/code/local/JestaSoft/AddTripId/etc/config.xml/app/code/local/JestaSoft/AddTripId/etc/config.xml

/app/code/local/JestaSoft/Model/Observer.php/app/code/local/JestaSoft/Model/Observer.php

/app/code/local/JestaSoft/AddTripId/etc/config.xml

/app/code/local/JestaSoft/Model/Observer.php

/app/code/local/JestaSoft/AddTripId/etc/config.xml

/app/code/local/JestaSoft/Model/Observer.php

Source Link

custom module generating 500 error

I have created a custom module to add a custom column to sales_flat_quote and sales_flat_order. I have been successful in creating the columns in the database. The problem is the module also has a observer for event controller_action_predispatch_checkout_onepage_index, but when the event is triggered i get 500 error message, and no error details is displayed.

/app/code/local/JestaSoft/AddTripId/etc/config.xml

<?xml version="1.0"?>
<config>
        <modules>
            <JestaSoft_AddTripId>
                    <version>0.1.0</version>
            </JestaSoft_AddTripId>
        </modules>
    <global>
            <resources>
                    <jestasoft_addtripid_setup>
                        <setup>
                                <module>JestaSoft_AddTripId</module>
                        </setup>
                        <connection>
                                <use>core_setup</use>
                        </connection>
                    </jestasoft_addtripid_setup>
            </resources>
            <fieldsets>
                <sales_convert_quote>
                    <trip_id>
                            <to_order>*</to_order>
                        </trip_id>
                </sales_convert_quote>

                <sales_convert_order>
                        <trip_id>
                            <to_order>*</to_order>
                        </trip_id>
                </sales_convert_order>
        </fieldsets>

            <events>
                <controller_action_predispatch_checkout_onepage_index>
                        <observers>
                            <jestasoft_addtripid>
                                    <class>JestaSoft_AddTripId_Model_Observer</class>
                                    <method>addTripId</method>
                            </jestasoft_addtripid>
                        </observers>
                </controller_action_predispatch_checkout_onepage_index>
            </events>
    </global>
</config>

/app/code/local/JestaSoft/Model/Observer.php

<?php

public function addTripId(Varien_Event_Observer $observer) {
    $item = $observer->getQuote();
    $tripId = Mage::getSingleton('checkout/session')->getNTripId();
    $item->setTripId($tripId);
    $item->save();
    return $this;
}
?>