If Registered user click on button, we are creating Product Programatically. but when guest user click on button , its creating product with empty product name

button :

<button  onclick="return setproductlogin(\'<?php echo 
id="submit-editorApply-{{rand}}" >SAVE DESIGN</button>


protected function _createProduct($type, $doSave=true, $originalProduct, $newImagePath="") 
        $product = Mage::getModel('catalog/product');

        $product->setDescription('what ever you need here');

        $customerId = Mage::getSingleton('customer/session')->getCustomerId();

        if ($doSave)

        return $product;

I tried below code, but didt worked for me

if($_category instanceof Mage_Catalog_Model_Category && $_category->getId()):



full controllers : https://pastebin.com/Gn6iMwug


when Registered user upload image or text and click on "Save Design" button in link , than Product creating with "Product Name".

enter image description here

When Guest user upload image or text and click on "Save Design" button in link , it will ask to login, once Guest login/register , Product is creating with empty Product name

enter image description here

After clicking save design, it redirect to another page :

enter image description here


2 Answers 2


This will only resolve your product Name issue.
Update your form action code to below.

<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect', array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'), 'id' => Mage::registry('current_product')->getId())) ?>

The product is being created without name is because you are not passing variable id which is required in your createSimpleProductAndRedirect function.

  • I thought when we pass : example/amasty/createSimpleProductAndRedirect , than thats going to be enough..... thanks a lot..... Commented Apr 11, 2017 at 7:01

I looked through your code and this is normal behavior.

Your $_category variable is never assigned.
This means that the condition $_category instanceof Mage_Catalog_Model_Category will always return false.
Because of that, your line $product->setName($originalProduct->getName()); will never get executed and you end up with a product without a name.
I'm not sure what you are trying to do, because you code looks fuzzy, but I'm sure that's why the problem appears.

  • thanks , I will dig deeper on this & come back to you.... Commented Apr 11, 2017 at 6:14
  • updated question, when you get free time, please check once..... Commented Apr 11, 2017 at 6:30
  • you added nothing relevant. I already told you what the problem is. Enable your error reporting and you will see your coding errors on the screen. This is basic PHP. You are using a variable that is not initialized.
    – Marius
    Commented Apr 11, 2017 at 6:32
  • oh sorry, i will check it..... Commented Apr 11, 2017 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.