magento 在自定义选项中添加QTY How to add custom qty to custom option of simple product

本文介绍如何在Magento中为简单产品的自定义选项添加数量字段。通过修改Magento的源代码,可以为不同颜色等选项设置不同的库存数量。具体步骤包括编辑PHP文件和数据库结构。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

By default in magento there is no qty field of simple product for custom option. If you want to add qty as per your custom option you can add now using this post.

Suppose you have custom option 'Color: Red, Blue, White' of your simple product and you want to add different qty option for your color option you can do it now.


1. go to 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>'+
 
Now add following code just after above code.
'<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>'+
 
Now add following code just after above code.
'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][qty]" value="{{qty}}"></td>'+

 

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

Find the below code: 

$value['sku'] = $this->htmlEscape($option->getSku());

 

Now add following code just after above code.
$value['qty'] = $this->htmlEscape($option->getQty());

 

Find the below code:

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

 

Now add following code just after above code.
'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',
 
Now clear your cache and check in you magento admin. You can hit below if post is help full for you.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值