Thursday, 25 April 2013

Add qty box in custom option row Magento



Add qty box in custom option row:



By default Magneto only provide custom options without ant qty, if you want to customize with Qty then you must change in following files:
  1.       app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml

·         Find the below code:
'<th class="type-sku"><?php echo Mage::helper('catalog')->__('SKU') ?></th>'+
Add these after just after
'<th class="type-qty"><?php echo Mage::helper('catalog')->__('Qty') ?></th>'+
·         Find the below code:
'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][sku]" value="{{sku}}"></td>'+
Add these after just after
'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][qty]" value="{{qty}}"></td>'+



  2.       app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php

·         Find the below code:

$value['sku'] = $this->htmlEscape($option->getSku());
Add these code  just after

$value['qty'] = $this->htmlEscape($option->getQty());

·         Find the below code:

'sku' => $this->htmlEscape($_value->getSku()),

Add these code  just after

'qty' => $this->htmlEscape($_value->getQty()),

   3.       Add field in “catalog_product_option_type_value” table

`qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty',


That’s all….

19 comments:

  1. Great work Bhaskar, thanks for sharing this. What would be better though is if the quantity field was linked to the quantity for the SKU's in the custom option.

    So rather than displaying an independent quantity field, grab the quantity field from the product that is already set in the database.

    Any ideas? :)

    ReplyDelete
  2. I have added a decsription field to the custom option now i want to display that description on the order detail page..Can you help me out .

    ReplyDelete
  3. i have added qty filed but data is not saving in db
    http://screencast.com/t/tEKOQtgaZ

    ReplyDelete
  4. Great - thank you.
    But how can i show same qty on frontend. I need it shown in a dropdown.

    ReplyDelete
  5. when i save the form,that shows error Indexer model is not defined

    ReplyDelete
  6. Nice work Bhaskar,But this qty will get decremented each time an order is placed with some value for this custom option ?

    ReplyDelete
    Replies
    1. yes i need qty will get decrement once order placed

      Delete
  7. Hi... Kindly reply this,If custom option product has purchased the qty is not reduced from the custom option qty field???

    ReplyDelete
  8. hi
    i followed al steps but i am stuck in last step
    kindly guide me on this please how to i add this
    Add field in “catalog_product_option_type_value” table

    `qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty',

    my database name is Database: yourstyl_eoutlet »Table: catalog_product_option_type_value
    please help

    ReplyDelete
  9. ALTER TABLE catalog_product_option_type_value ADD `qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty'

    ReplyDelete
  10. Very Nice... thanks for sharing this useful information.
    Ecommerce web Development in mumbai

    ReplyDelete
  11. Hi Bhaskar,

    I am stuck on the last step. Could you guide me through it please.

    Thanks

    ReplyDelete
    Replies
    1. Hello,

      Find below steps to add qty in table:

      1. open database and fine table "catalog_product_option_type_value"
      2. click on table then you show the data grid
      3. Add new Column 'qty'
      OR
      open a query window and add below query :

      ALTER TABLE catalog_product_option_type_value ADD `qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty'

      Now qty add in your database table.


      Delete
    2. this is really very useful, thank you.
      But when we place an order, we need that decrement the custom otion qty, which is not happening .
      How can we fix it please ?

      Delete
  12. Hi Bhaskar,

    First of all i would like to thanks for this informational article its really help me. Can you please guide me how can I show the qty box on front-end as well for the same.

    Thanks in Advance !!

    ReplyDelete
  13. Hi,
    I want to decrease quantity from database when we place order . how can i do that?

    ReplyDelete
  14. It is a good article , but without frontend control then it is not useful, could you please add the front end section
    Thank you in advanced

    ReplyDelete