Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $product->setName($originalProduct->getName());
- protected function _createit()
- {
- // Clear the messages each time we call it
- Mage::getSingleton('core/session')->getMessages(true);
- if (version_compare(Mage::getVersion(),"1.9.2.2",">="))
- {
- // Only from 1.9.2.2
- if (!$this->_validateFormKey()) {
- return;
- }
- }
- $session = Mage::getSingleton('customer/session');
- if ($session->isLoggedIn()) {
- return;
- }
- $session->setEscapeMessages(true); // prevent XSS injection in user input
- if (!$this->getRequest()->isPost()) {
- return;
- }
- $result = array(
- 'success' => false
- );
- $customer = $this->_getCustomer();
- try {
- $errors = $this->_getCustomerErrors($customer);
- if (empty($errors)) {
- if (version_compare(Mage::getVersion(),"1.9.1.0",">="))
- {
- // Only from 1.9.1.0
- $customer->cleanPasswordsValidationData();
- }
- $customer->save();
- Mage::dispatchEvent('customer_register_success',
- array('account_controller' => $this, 'customer' => $customer)
- );
- $result['redirect'] = $this->_successProcessRegistration($customer);
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
- $productId=$this->getRequest()->getPost('product_id');
- // code for register end
- Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
- $product = Mage::getModel('catalog/product');
- /
- $rand = rand(1, 9999);
- $product->setTypeId($type)
- ->setAttributeSetId(17)
- ->setSku('CDSB1_sku' . $rand) /
- ->setWebsiteIDs(array(
- 1
- ));
- $product->setName($originalProduct->getName());
- $customerId = Mage::getSingleton('customer/session')->getCustomerId();
- $product->setCreatedByCustomerId($customerId);
- if ($doSave)
- $product->save();
- return $product;
- // code for register start
- }
- } catch (Mage_Core_Exception $e) {
- $session->setCustomerFormData($this->getRequest()->getPost());
- if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
- $url = Mage::getUrl('customer/account/forgotpassword');
- $message = $this->__('There is already an account.', $url);
- $session->setEscapeMessages(false);
- } else {
- $message = $e->getMessage();
- }
- $result['error'] = $message;
- }
- catch (Exception $e) {
- // $result['error'] = $this->__('Cannot save the customer.');
- }
- Mage::unregister('isSecureArea');
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
- }
- <?php if (!Mage::getSingleton('customer/session')->isLoggedIn()): ?>
- <form action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect1',
- array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'),
- 'id' => Mage::registry('current_product')->getId() )) ?>"
- method="post" id="ajaxlogin-create-form">
- <?php echo $this->getChildHtml(); ?>
- </form>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement