I have a custom module which does same function of product view page. I am using this module in order to show my bundle products. i have created a fully functional module for this.

I have loaded the product successfully and displayed products name,description, different options in my page. However my add to cart button is not working.

I am loading my product like this

/*getInternationalPlans() is a custom function which filter out bundle products that 
  satisfy certain conditions. there may be more than one bundle products for this   
foreach ( $_product as $product ){
$plan_array [] = $product->getId ();

 /*it unregisters the product  */
  Mage::unregister ( 'product' );
  Mage::register('international_product',$plan_array[0]);// i need only the first product                       
/*  loading the current product*/  
 /*registering the current product*/
 Mage::register('product', $_product); // add the product object in the registry                    
 $block = Mage::getBlockSingleton('Mage_Catalog_Block_Product_View'); // Instantiate the product view block


but in default product view page prdoucts are loading using getProduct() method. my form is like this... which is exactly same as that of default one

 <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post"
  <?php if($_product->getOptions()): ?> enctype="multipart/form-data"
 <?php endif; ?>> 
       /*all options are showing here*/
         $buttonTitle = $this->__('Order Now');
         <button type="button" title="<?php echo $buttonTitle ?>" id="international_btn" class="btn btn-success" onclick="productAddToCartForm.submit(this)">

However the action part of form is blank, after I load this code. when I click on the button, it loads the same page again and during consoling it says that 'productId is not defined'. So I have checked 'productAddToCartForm ' definition and found out that it uses 'productId' in its definition. How can I set 'prdouctId' in my page? why form action field is empty?

how can make my order now button work perfectly?

Please help me...


2 Answers 2


On the standard layout there is a hidden field that sets this in the product view template (/app/design/frontend/base/default/template/catalog/product/view.phtml):

<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />

I would suggest with your code you could simple add this hidden field after the form is opened.

The form gets the action from calling $this->getSubmitUrl($_product). If you look into the class Mage_Catalog_Block_Product_Abstract you will see the default way of getting this. The easiest option would be to make sure that your block extends this class or another block that extends it (e.g. Mage_Catalog_Block_Product_View). Something like the following would be enough.

class Your_Catalog_Block_Product_View extends Mage_Catalog_Block_Product_Abstract
  • i have added following code.. but it didnt work. loads the same page again. why action field of form is empty? Dec 16, 2013 at 16:00
  • Oh sorry I miss read your question. What block are you using to show this form? As you will need the action from the block abstract Mage_Catalog_Block_Product_Abstract Dec 16, 2013 at 16:02
  • i copied the form element definition from view.phtml file and pasted it in my custom view.phtml page. since i have loaded the prdouct to the variable $_product, i assumed that, it may work like standard form element definition. howewver it didnt worked. please note that, i am not using any of standard blocks in my custom module. Dec 16, 2013 at 16:06
  • see my edit about the Mage_Catalog_Block_Product_Abstract as this holds the getSubmitUrl code Dec 16, 2013 at 16:07
  • what should i do in order to get this action from Mage_Catalog_Block_Product_Abstract? Dec 16, 2013 at 16:13

You does not add this Block in Form

 <?php echo $this->getBlockHtml('formkey') ?>

or you can also add this in form

 <input type="hidden" value="<?php Mage::getSingletonModel('core/session')->getFormKey()?>" name="form_key">

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.