数量未在magento网站更新 [英] Quantity is not updating in magento site
问题描述
我们有多个供应商/卖家网站。我们给卖家选择通过前端更新产品信息.....
we have marketplace multi vendor/seller site. we gave an option for seller to update the product information through frontend.....
由于是市场网站,我们有很多卖家。
As it is marketplace site, we have many sellers.
卖家上传的商品A在frontend [quantity = 20]
seller A uploaded product A in frontend [quantity = 20 ]
如果卖家B有相同的产品,他会分配相同的产品他的帐户[quantity = 5]
if seller B have same product , he will assign the same product to his account [quantity = 5 ]
在后端显示20 + 5 = 25的数量。
in backend it showing 20 + 5 = 25 quantity.
问题是卖家A更新数量从20到40,它显示40在前端,一旦我们刷新页面,它只显示35.刷新后的手段显示数量 [卖家A qty-卖家B qty] / strong>
now the problem is when seller A update the quantity from 20 to 40, it showing 40 in frontend and once we refresh the page, it showing only 35. Means after refreshing it showing quantity of [ Seller A qty- Seller B qty ]
但应显示卖家A 数量。
工作正常,后来我们做了一些代码更改,比我们面临的这个问题。
Before It was working properly , later we did some code changes than we are facing this Problem.
之前的qty textfield看起来像图像:
before the qty textfield was looking like as in image :
一旦我们点击图片中的编辑按钮,下面的图片:
once we click on "edit " button present in image, it looks like below image :
但我们决定显示以下图片:
But we decided to display below image :
因此我们将代码更改为看起来像上面的图像。比这个问题发生了。
so we changed code to look like above image. Than this problem happened.
之前的代码:[一切都很顺利]
Before Code : [Everything was working fine ]
<td>
<?php
$selllermpassignproduct=Mage::getModel('mpassignproduct/mpassignproduct')->getAssignProDetails($products->getId());
//Zend_Debug::dump($selllermpassignproduct,null,true);
$stock_item=Mage::getModel('cataloginventory/stock_item')->loadByProduct($products);
$SellerQty=isset($selllermpassignproduct['sellerqty'])?$selllermpassignproduct['sellerqty']:$stock_item->getQty();
$assignqty=isset($selllermpassignproduct['assignqty'])?$selllermpassignproduct['assignqty']:0;
?>
<span id="valueqty_<?php echo $products->getId(); ?>"><?php echo (int) $SellerQty; ?></span>
<input type = "text" id = "qty_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name = "stock" value = "<?php echo (int) $SellerQty; ?>" style = "display:none"/>
<span class="label wk_action" id="edit_link_<?php echo $products->getId(); ?>">
<img onclick="showField('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>"/>
</span>
<p id="updatedqty_<?php echo $products->getId(); ?>" style = "display:none;color:red;">Updated</p>
<br/>
<button id="update_button_<?php echo $products->getId(); ?>" class="buttons" onclick="updateField('<?php echo $products->getId(); ?>',<?php echo $assignqty;?>); return false;" style="display:none" >
<span><span style="font-size:12px;"><?php echo $helper->__('Update') ?></span></span>
</button>
<button id="reset_button_<?php echo $products->getId(); ?>" type="reset" class="cancel" onclick="hideReset('<?php echo $products->getId(); ?>'); return false;" style="display:none" >
<span><span><?php echo $helper->__('Cancel') ?></span></span>
</button>
脚本
function hideReset(product_id) {
var qtyId='#qty_'+ product_id;
var editLink="#edit_link_"+ product_id;
var updateButton="#update_button_"+ product_id;
var resetButton="#reset_button_"+ product_id;
$wk_jq(qtyId).hide();
$wk_jq(editLink).show();
$wk_jq(updateButton).hide();
$wk_jq(resetButton).hide();
}
function updateField(product_id,assignqty)
{
var qtyId = '#qty_'+ product_id;
var valueId = '#valueqty_'+ product_id;
var updatedqty = '#updatedqty_'+ product_id;
var editLink = "#edit_link_"+ product_id;
var updateButton = "#update_button_"+ product_id;
var resetButton = "#reset_button"+ product_id;
var url ='<?php echo Mage::getUrl('marketplace/marketplaceaccount/updateField/')?>';
$wk_jq(qtyId).toggle()
$wk_jq(editLink).hide();
$wk_jq(updateButton).show();
$wk_jq(resetButton).show();
$qty = $wk_jq(qtyId).val();
jQuery(valueId).html($qty);
hideReset(product_id);
var tmpQty=assignqty+ parseInt($qty) ;
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, qty: tmpQty},
onComplete: function (transport) {
//alert(transport.responseText);
jQuery(priceId).val($price);
// $wk_jq(priceId).setValue($price);
jQuery(updatedqty).show().delay(2000).fadeOut();
$updateButton.prop('disabled', false);
// $wk_jq(qtyId).setValue($qty);
}
});
}
现有代码
在上面的代码中,我们注释了一些行,并替换了以下代码。
In the above code, we comment some lines and we replaced some codes as below.
注释代码 / p>
commented code
<!-- <img onclick="showField('<?php echo $products->getId(); ?>'); return false;" src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?> -->
**script**
//$wk_jq(qtyId).toggle()
//$wk_jq(updateButton).show();
//hideReset(product_id);
//jQuery(updatedqty).show().delay(2000).fadeOut();
<替换代码1)
Replaced code 1 )
<input type = "text" id = "qty_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name = "stock"
value = "<?php echo (int) $SellerQty; ?>" style = "display:none"/>
>
to
<input type = "text" id = "qty_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)"
name = "stock" class="ama1" value = "<?php echo (int) $SellerQty; ?>" />
替换代码2) >
Replaced code 2)
var tmpQty=assignqty+ parseInt($qty) ;
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, qty: tmpQty},
到
var tmpQty=parseInt(assignqty)+ parseInt($qty) ;
new Ajax.Request(url, {
method: 'post',
parameters: {id: product_id, qty: $qty},
推荐答案
我找到第一个问题的解决方案。
I found solution for 1st problem.
public function massupdatesellerproAction(){
if($this->getRequest()->isPost()){
if(!$this->_validateFormKey()){
$this->_redirect('marketplace/marketplaceaccount/myproductslist/');
}
$ids= $this->getRequest()->getParam('product_mass_update');
$price= $this->getRequest()->getParam('price');
$special= $this->getRequest()->getParam('specialprice');
$i=1;
foreach ($ids as $key => $value) {
$i=$i+1;
$qty = $this->getRequest()->getParam('stock'.$i);
$product = Mage::getModel('catalog/product')->load($value);
$product->setPrice($price[$key]);
$product->setSpecialPrice($special[$key]);
//$product->setQty($qty);
$product->save();
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($value);
$stockItem->setData('manage_stock', 1);
$stockItem->setData('qty', $qty);
$stockItem->save();
}
Mage::getSingleton('core/session')->addSuccess( Mage::helper('marketplace')->__('Products has been sucessfully deleted from your account'));
$this->_redirect('marketplace/marketplaceaccount/myproductslist/');
}}
这篇关于数量未在magento网站更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!