If the Registered user click on "save design" button we are creating new product.
Issue : But if guest user click on "save design" button, we are displaying pop up box to register or login. once guest user logged in, **new Product is not creating****
controllers
protected function _createProduct($type, $doSave=true, $originalProduct, $newImagePath="")
{
$product = Mage::getModel('catalog/product');
$product->setName($originalProduct->getName());
$product->setDescription('what ever you need here');
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
$product->setCreatedByCustomerId($customerId);
if ($doSave)
$product->save();
return $product;
}
Edit
Now we can able to create new product once guest user click on button, but guest user is not logged in and we need to assign the Created product to Guest user similar to Registered user
<?php if (!Mage::getSingleton('customer/session')->isLoggedIn()): ?>
<div id="ajaxlogin-login-window" style="display: none;">
<span><?php echo $this->__('Login into your Account 4') ?></span>
<form action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'), 'id' => Mage::registry('current_product')->getId())) ?>" id="ajaxlogin-login-form">
// form code login/Register in pop up box
</form>
<script type="text/javascript">
//<![CDATA[
var ajaxLoginForm = new VarienForm('ajaxlogin-login-form', true);
jQuery("#ajaxlogin-login-form").submit(function(e) {
e.preventDefault();
if (ajaxLoginForm.validator.validate()) {
jQuery.ajax({
type: "POST",
url: jQuery('#ajaxlogin-login-form').attr('action'),
}).done(function(result) {
alert(result);
}).fail(function() {
alert('There is some error saving your design.');
});
}
});
//]]>
</script>
</div>
<?php endif; ?>
function loginAction()
& add tofunction _createProduct