2016-02-25 74 views
0

我們有市場多供應商/賣家網站。我們給了賣家通過前端更新產品信息的選項.....數量未更新magento網站

因爲它是市場站點,我們有很多賣家。

賣方甲上傳產物A在前端[量= 20]

如果賣方B具有相同的產品時,他將在同一產品分配給他的帳戶[量= 5]

在後端它示出20 + 5 = 25數量。

現在的問題是,當賣家A更新數量從20到40,它顯示40在前端,一旦我們刷新頁面,它只顯示35.意味着刷新後顯示數量[Seller A qty- B數量]

但它應該顯示賣家A數量。

在它正常工作之前,後來我們做了一些代碼更改,而不是我們面臨的這個問題。

的數量文本框之前一直在尋找類似的圖像:

enter image description here

一旦我們點擊「編輯」出現在圖像按鈕,它看起來像下面的圖片:

enter image description here

但我們決定展示下圖:

enter image description here

所以我們改變了代碼,看起來像上面的圖像。比這個問題發生了。

代碼:之前 [一切都很好,工作]

<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); 



       } 
      }); 
     } 

本次代碼

在上面的代碼中,我們發表評論的一些線路和我們替換了一些代碼如下。

註釋的代碼

<!-- <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)

<input type = "text" id = "qty_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" name = "stock" 
    value = "<?php echo (int) $SellerQty; ?>" style = "display:none"/> 

<input type = "text" id = "qty_<?php echo $products->getId(); ?>" onkeydown="validateNumbers(event)" 
name = "stock" class="ama1" value = "<?php echo (int) $SellerQty; ?>" /> 

代替代碼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}, 

回答

0

我發現對於第一問題的解決方案。

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/'); 
    }}