Question

we are using following code for updating quantity in file2.phtml file :

enter image description here

<li class="fields">
<div class="customer-name">
<div class="field">
<div class="input-box">
<input type="text" name="qty" id="qty" value="<?php echo intval($mpAssignProductModel->getQty()) ?>" class="required-entry validate-zero-or-greater input-text"/>
</div>
</div>
</div>
</li>

i copied this code in file 1, now in file1.phtml page, its displaying like this :

enter image description here

means correct quantity value [20 ] showing in file2.phtml page , but in file1.phtml page, its showing "0" as quantity

full code for file1.phtml, file2.phtml

Edit

for debug, i used this code : <?php var_dump($id); ?> , its displaying NULL

Was it helpful?

Solution

Try to use the $assinproducts instead of the $mpAssignProductModel in the file1.phtml. You should add your input with qty after the condition:

<?php foreach($this->getCollection() as $assinproducts):  ?>

Complete code should looks like this:

<tbody>
<?php foreach ($this->getCollection() as $assinproducts): ?>
    <?php $products = Mage::getModel('catalog/product')->load($assinproducts->getProductId()); ?>
    <tr class="wk_row_view ">
        <td>
            <input type="text" name="qty" id="qty" value="<?php echo intval($assinproducts->getQty()) ?>" class="required-entry validate-zero-or-greater input-text"/>
        </td>
....

But beware because you can have more than one item in the table. At bottom of the code you can see the original qty input (with id increment in the name) and I strongly recommend you use the original input field:

<td>
    <span class="label qty" id="valueqty_<?php echo $assinproducts->getId(); ?>">
        <?php echo intval($assinproducts['qty']); ?>
    </span>
    <input type="text" id="qty_<?php echo $assinproducts->getId(); ?>"
           onkeydown="validateNumbers(event)"
           name="stock" value="<?php echo intval($assinproducts['qty']); ?>"
           style="display:none;"/>

    <span class="label wk_action" id="edit_link_<?php echo $assinproducts->getId(); ?>">
        <img onclick="showField('<?php echo $assinproducts->getId(); ?>'); return false;"
             src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
    </span>

    <p id="updatedqty_<?php echo $assinproducts->getId(); ?>"
       style="display:none;color:red;">Updated</p><br/>

    <button id="update_button_<?php echo $assinproducts->getId(); ?>"
            class="button wk_mp_btn1"
            onclick="updateField('<?php echo $assinproducts->getId(); ?>',<?php echo intval($assinproducts['qty']); ?>); return false;"
            style="display:none">
        <span>
            <span style="font-size:12px;"><?php echo $helper->__('Update') ?></span>
        </span>
    </button>

    <button id="reset_button_<?php echo $assinproducts->getId(); ?>"
            type="reset" class="cancel"
            onclick="hideReset('<?php echo $assinproducts->getId(); ?>'); return false;"
            style="display:none"></button>
</td>

PS: Please tell me if I have mixed files and I will update the answer

OTHER TIPS

You have load model using id.

so your code not working

$mpAssignProductModel->getQty();

Change it to:

$mpAssignProductModel->getData('qty');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top