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()); } } } } } |
[crayon-63d3e95ef2f14482168130/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.