0

we have a marketplace site, where each seller/vendor have different accounts. we are displaying products infromation in their account in frontend. we want to provide a seller an option for editing the quantity we are using this code : http://pastebin.com/RTYvpS0W to display the list of product name, sku , quantity. we are using following code to edit the quantity

    <td>
    <?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
    <input type="text" id="qty_<?php echo $product_id;?>" name="qty" value="<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>" style="display:none"/>
    <span class="label wk_action">
        <img onclick="updateField('<?php echo $product_id; ?>');return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>   
</td>


<?php $url = Mage::getUrl('module_name/index/updateField/'); ?>

<script type = "text/javascript" >

    var $wk_jq = jQuery.noConflict();

    function updateField(product_id)
    {
        var qtyId = '#qty_'+product_id;

        $wk_jq(qtyId).toggle()

        $qty = $wk_jq(qtyId).val();

        new Ajax.Request('<?php echo $url ?>', {
            method: 'post',
            parameters: {id: product_id, qty: $qty}
        });
    }
</script>

but its working only for first product, please help me what code have to replace to work it for all products

3

1 Answer 1

1

Change below code

<input type = "text" id = "qty_<?php echo $product_id; ?>" name = "qty" value = "<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>" style = "display:none"/>
<span class = "label wk_action">
    <img onclick = "updateField('<?php echo $product_id; ?>');
            return false;" src = "<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>

To

<input type = "text" id = "qty_<?php echo $products->getId(); ?>" name = "qty" value = "<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>" style = "display:none"/>
<span class = "label wk_action">
    <img onclick = "updateField('<?php echo $products->getId(); ?>');
            return false;" src = "<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>   
1
  • now update button is working for all products. please help me for saving the quantity in database i am using this code in controller file: pastebin.com/20un3uT8 but its not working Commented Oct 28, 2015 at 9:16

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.