Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. $product->setName($originalProduct->getName());
  2.  
  3. protected function _createit()
  4. {
  5. // Clear the messages each time we call it
  6. Mage::getSingleton('core/session')->getMessages(true);
  7.  
  8. if (version_compare(Mage::getVersion(),"1.9.2.2",">="))
  9. {
  10. // Only from 1.9.2.2
  11. if (!$this->_validateFormKey()) {
  12. return;
  13. }
  14. }
  15.  
  16. $session = Mage::getSingleton('customer/session');
  17.  
  18. if ($session->isLoggedIn()) {
  19. return;
  20. }
  21.  
  22. $session->setEscapeMessages(true); // prevent XSS injection in user input
  23. if (!$this->getRequest()->isPost()) {
  24. return;
  25. }
  26.  
  27. $result = array(
  28. 'success' => false
  29. );
  30.  
  31. $customer = $this->_getCustomer();
  32.  
  33. try {
  34. $errors = $this->_getCustomerErrors($customer);
  35.  
  36. if (empty($errors)) {
  37. if (version_compare(Mage::getVersion(),"1.9.1.0",">="))
  38. {
  39. // Only from 1.9.1.0
  40. $customer->cleanPasswordsValidationData();
  41. }
  42. $customer->save();
  43. Mage::dispatchEvent('customer_register_success',
  44. array('account_controller' => $this, 'customer' => $customer)
  45. );
  46. $result['redirect'] = $this->_successProcessRegistration($customer);
  47. $customerId = Mage::getSingleton('customer/session')->getCustomerId();
  48. $productId=$this->getRequest()->getPost('product_id');
  49.  
  50. // code for register end
  51.  
  52. Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
  53.  
  54. $product = Mage::getModel('catalog/product');
  55.  
  56. /
  57. $rand = rand(1, 9999);
  58. $product->setTypeId($type)
  59. ->setAttributeSetId(17)
  60. ->setSku('CDSB1_sku' . $rand) /
  61. ->setWebsiteIDs(array(
  62. 1
  63. ));
  64.  
  65.  
  66. $product->setName($originalProduct->getName());
  67.  
  68. $customerId = Mage::getSingleton('customer/session')->getCustomerId();
  69. $product->setCreatedByCustomerId($customerId);
  70.  
  71. if ($doSave)
  72. $product->save();
  73.  
  74. return $product;
  75.  
  76. // code for register start
  77. }
  78.  
  79. } catch (Mage_Core_Exception $e) {
  80.  
  81. $session->setCustomerFormData($this->getRequest()->getPost());
  82. if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
  83. $url = Mage::getUrl('customer/account/forgotpassword');
  84. $message = $this->__('There is already an account.', $url);
  85. $session->setEscapeMessages(false);
  86. } else {
  87. $message = $e->getMessage();
  88. }
  89. $result['error'] = $message;
  90.  
  91. }
  92.  
  93. catch (Exception $e) {
  94.  
  95. // $result['error'] = $this->__('Cannot save the customer.');
  96. }
  97.  
  98.  
  99. Mage::unregister('isSecureArea');
  100. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
  101.  
  102. }
  103.  
  104. <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()): ?>
  105. <form action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect1',
  106. array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'),
  107. 'id' => Mage::registry('current_product')->getId() )) ?>"
  108. method="post" id="ajaxlogin-create-form">
  109.  
  110. <?php echo $this->getChildHtml(); ?>
  111. </form>
  112.  
  113. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement