Create app/code/local/Namespace/Module/etc/config.xml file and add below code
1 2 3 4 5 6 7 8 9 10 11 12 |
<events> <checkout_onepage_controller_success_action> <!-- identifier of the event we want to catch --> <observers> <checkout_onepage_controller_success_action_handler> <!-- identifier of the event handler --> <type>singleton</type> <!-- class method call type; valid are model, object and singleton --> <class>createcustomer/observer</class> <!-- observers class alias --> <method>Aftersuccess</method> <!-- observer's method to be called --> <args></args> <!-- additional arguments passed to observer --> </checkout_onepage_controller_success_action_handler> </observers> </checkout_onepage_controller_success_action> </events> |
Create app/code/local/Namespace/Module/Model/Observer.php file and add the below code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
<?php class Namespace_Module_Model_Observer { public function Aftersuccess(Varien_Event_Observer $observer) { $orderIds = $observer->getData('order_ids'); foreach($orderIds as $_orderId){ $order = Mage::getModel('sales/order')->load($_orderId); $storeId = Mage::app()->getStore()->getId(); $store = Mage::getModel('core/store')->load($order->getData('store_id')); $websiteId = $store->getWebsiteId(); $billingaddress = $order->getBillingAddress(); $customer = Mage::getModel('customer/customer')->setWebsiteId($websiteId); $customer->loadByEmail($order->getCustomerEmail()); if(!$customer->getId()) { $customer = Mage::getModel("customer/customer"); $customer ->setWebsiteId($websiteId) ->setStore($store) ->setFirstname($billingaddress->getFirstname()) ->setLastname($billingaddress->getLastname()) ->setEmail($billingaddress->getEmail()); try{ $customer->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); } $address = Mage::getModel("customer/address"); $address->setCustomerId($customer->getId()) ->setFirstname($customer->getFirstname()) ->setMiddleName($customer->getMiddlename()) ->setLastname($customer->getLastname()) ->setCountryId($billingaddress->getCountryId()) ->setRegionId($billingaddress->getRegionId()) //state/province, only needed if the country is USA ->setPostcode($billingaddress->getPostcode()) ->setCity($billingaddress->getCity()) ->setTelephone($billingaddress->getTelephone()) ->setFax($billingaddress->getFax()) ->setCompany($billingaddress->getCompany()) ->setStreet($billingaddress->getStreet()) ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1'); try{ $address->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); } } } } } |
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-62846fe14423a351076358/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...