Javascript magento编辑数量而不重定向到其他页面

Javascript magento编辑数量而不重定向到其他页面,javascript,php,html,css,magento,Javascript,Php,Html,Css,Magento,我们有一个市场网站。每个卖方/供应商都有自己的账户 我们正在他们的帐户中显示卖方产品、数量、sku…等的列表 我们使用此代码显示这些信息: <?php $isPartner= Mage::getModel('marketplace/userprofile')->isPartner(); $helper= Mage::helper('marketplace'); if($isPartner==1){ ?> <script type="text/java

我们有一个市场网站。每个卖方/供应商都有自己的账户

我们正在他们的帐户中显示卖方产品、数量、sku…等的列表

我们使用此代码显示这些信息:

<?php 
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner(); 
$helper= Mage::helper('marketplace');
if($isPartner==1){
    ?>
    <script type="text/javascript">
    if (typeof jQuery == 'undefined'){
        document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
    }
    </script>
    <script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <div class="page-title">
        <h1 style="float:left;"><?php echo $helper->__('My Product List') ?></h1>
    </div>  
    <div class="wk_mp_design">
        <div class="block block-account">   
            <div class="block-title">   
                <strong><span><h4><?php echo $helper->__('Product List') ?></h4></span></strong>
            </div>
        </div>
        <div class="fieldset wk_mp_fieldset">
            <div class="grid">
                <div class="hor-scroll">
                    <form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
                        <table cellspacing="0" class="border wk_mp_list_table">
                            <thead>
                                <tr id="wk_mp_tr_heading">
                                    <th><span><?php echo $helper->__('Product Name') ?></span></th>
                                    <th><span><?php echo $helper->__('Date') ?></span></th>
                                    <th><span><?php echo $helper->__('Product Status') ?></span></th>
                                    <th><span>&nbsp;</span></th>
                                </tr>
                            </thead>
                            <tbody class="wk_mp_body">
                                <tr>
                                    <td>
                                        <input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
                                    </td>
                                    <td>
                                        <span class="wk_mp_td_span">
                                            <?php echo $helper->__('From: ') ?>
                                            <input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
                                        </span>                             
                                        <span class="wk_mp_td_span">
                                            <?php echo $helper->__('To: ') ?>
                                            <input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
                                        </span>
                                    </td>
                                    <td>
                                        <select name="prostatus" class="input-text">
                                            <option value=""><?php echo $helper->__('All') ?></option>
                                            <option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
                                                <?php echo $helper->__('Approved') ?>
                                            </option>
                                            <option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
                                                <?php echo $helper->__('Unapproved') ?>
                                            </option>
                                        </select>
                                    </td>
                                    <td>
                                        <button class="button" title="Save" type="submit">
                                            <span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
                                        </button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </form>
                    <?php 
                    if(count($this->getCollection())==0){ ?>        
                        <div class="fieldset wk_mp_fieldset">
                            <div class="wk_emptymsg">
                                <?php echo $helper->__('No Product Available') ?>
                            </div>
                        </div>
                        <?php 
                    } else{ ?>
                        <form action="<?php echo $this->getUrl('marketplace/marketplaceaccount/massdeletesellerpro') ?>" method="post" id="formmassdelete" name="formmassdelete">
                            <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
                            <button class="button" title="<?php echo $helper->__('Delete Products') ?>" type="submit" style="float: left;padding: 5px 5px 5px 0;"  id="mass_delete_butn">
                                <span><span><?php echo $helper->__('Delete Products') ?></span></span>
                            </button>
                            <table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
                                <thead>
                                    <tr class="wk_content">
                                        <th class="wk_check_first_td">
                                            <span>
                                                <input type="checkbox" name="mpselecctall" value="all" id="mpselecctall"/>
                                            </span>
                                        </th>
                                        <th class="wk_first_td">
                                            <span class="label name">
                                                <?php echo $helper->__('Product')?>
                                            </span>
                                        </th>
                                        <th class="wk_first_td">
                                            <span class="label name">
                                                <?php echo $helper->__('sku')?>
                                            </span>
                                        </th>
                                        <th>
                                            <span class="label pro_status">
                                                <?php echo $helper->__('Status')?>
                                            </span>
                                        </th>

                                        <!--
                                        <th>
                                            <span class="label qty">
                                                <?php echo $helper->__('Qty. Confirmed')?>
                                            </span>
                                        </th>
                                        <th>
                                            <span class="label qty">
                                                <?php echo $helper->__('Qty. Pending')?>
                                            </span>
                                        </th>   
                                        <th>
                                            <span class="label qty">
                                                <?php echo $helper->__('Qty. Sold')?>
                                            </span>
                                        </th>
                                        -->
                                        <th>
                                            <span class="label">
                                                <?php echo $helper->__('Qty')?>
                                            </span>
                                        </th>

                                        <th>
                                            <span class="label">
                                                <?php echo $helper->__('Earn Amount')?>
                                            </span>
                                        </th>
                                        <th>
                                            <span class="label">
                                                <?php echo $helper->__('Action')?>
                                            </span>
                                        </th>                       
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                    $i = 0;
                                    foreach($this->getCollection() as $products){
                                        $i++;
                                        $productMediaConfig = Mage::getModel('catalog/product_media_config');
                                        $salesdetail=Mage::getModel('marketplace/saleslist')->getSalesdetail($products->getEntityId());
                                        ?>
                                        <tr class="wk_row_view <?php echo $class = ($i == count($this->getCollection()))? 'wk_last_tr':''?>">
                                            <td class="wk_check_first_td">
                                                <span>
                                                    <input type="checkbox" name="product_mass_delete[]" class="mpcheckbox" value="<?php echo $products->getEntityId(); ?>"/>
                                                </span>
                                            </td>
                                            <td class="wk_first_td">
                                                <input type="hidden" class="hidden_id" value="<?php echo $products->getEntityId(); ?>" />
                                                <div class="label name" title="<?php echo $products->getName(); ?>">
                                                    <div class="wk_pro_divide1">
                                                        <img src="<?php echo Mage::helper('catalog/image')->init($products,'thumbnail');?>" class="image" />
                                                    </div>
                                                    <div class="wk_pro_divide2">
                                                        <div style="width:100%;">
                                                            <a href="<?php echo $this->getUrl($products->getUrlPath())?>" target="blank">
                                                                <?php echo $products->getName();?>
                                                            </a>
                                                        </div>
                                                        <div style="width:100%;float:left;">
                                                            <?php echo Mage::helper('core')->currency($products->getPrice(), true, false);?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </td>

                                            <td>
                                            <?php echo $sku = Mage::getModel('catalog/product')->load($products->getId())->getSku();?>
                                            </td>


                                            <?php 
                                            if($products->getStatus()==2) { ?>
                                                <td>        
                                                    <span class="label pro_status">
                                                        <?php echo $helper->__('Pending')?>
                                                    </span>
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $helper->__('Pending')?>
                                                    </span>
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $helper->__('Pending')?>
                                                    </span> 
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $helper->__('Pending')?>
                                                    </span> 
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $helper->__('Pending')?>
                                                    </span> 
                                                </td>                                   
                                            <?php }
                                            else{ 
                                                $id=$products->getId();
                                                $productsolddetail=Mage::getModel('marketplace/saleslist')->getProductSalesDetailById($id);
                                                $qtycom=0;
                                                $com=0;
                                                foreach($productsolddetail as $key){
                                                    $qtycom+=$key['magequantity'];
                                                    $com+=$key['actualparterprocost'];
                                                }   ?>

                                                <td>        
                                                    <span class="label pro_status">
                                                        <?php echo $helper->__('Approved')?>
                                                    </span>
                                                </td>

                                                <!--    edit qty -->
                                                <td>

                                                <?php echo (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>

                                                     <span class="label wk_action">
                                                    <img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>

                                                     </span>    
                                                </td>

                                               <!-- edit qty end -->


                                                <!--
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $salesdetail['quantitysoldconfirmed']; ?>
                                                    </span>
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <?php echo $salesdetail['quantitysoldpending']; ?>
                                                    </span> 
                                                </td>
                                                <td>
                                                    <span class="label qty">
                                                        <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/salesdetail/')."id/".$products->getId(); ?>"><?php echo $salesdetail['quantitysold']; ?></a>
                                                    </span> 
                                                </td>
                                                -->
                                                <td>
                                                    <span class="label price">
                                                        <?php echo Mage::helper('core')->currency($salesdetail['amountearned'], true, false); ?>
                                                    </span> 
                                                </td>
                                                <?php 
                                            }?>
                                            <td>
                                                <span class="label wk_action">
                                                    <img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
                                                    <img src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
                                                </span> 
                                            </td>                       
                                        </tr>
                                        <?php
                                    }?>
                                </tbody>
                            </table>
                        </form>
                        <?php
                    }?>
                </div>
            </div>
            <?php echo $this->getPagerHtml(); ?>        
        </div>  
        <div class="buttons-set">
            <p class="back-link">
                <a href="javascript:;" onclick="javascript: window.history.back();" class="left">&laquo; <?php echo $helper->__('Back') ?></a>
            </p>
        </div>
    </div>
    <script> 
    var $wk_jq=jQuery.noConflict();
    var newCustomerProductForm1 = new VarienForm('formmassdelete', true);
    (function($wk_jq){
        $wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
        $wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
        $wk_jq('body').delegate('.mp_edit','click',function(){
            var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();   
            var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
            if(dicision==true){         
                var $type_id=$wk_jq(this).attr('data-type');                
                if($type_id=='simple')
                    window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedsimple/') ?>".concat("id/",id); 
                if($type_id=='downloadable')
                    window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapproveddownloadable/') ?>".concat("id/",id);           
                if($type_id=='virtual')
                    window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedvirtual/') ?>".concat("id/",id);        
                if($type_id=='configurable')
                    window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedconfigurable/') ?>".concat("id/",id);
                if($type_id=='grouped')
                    window.location = "<?php echo $this->getUrl('mpgroupproduct/index/editapprovedgrouped/') ?>".concat("id/",id);
                    <?php
                    //echo $this->getChildHtml('mpgrouped_productslist');
                    // echo $this->getChildHtml('mpbundle_productslist');
                    ?>
                if($type_id=='bundle')
                    window.location = "<?php echo $this->getUrl('mpbundleproduct/index/editbundle/') ?>".concat("id/",id);
            }
        });
        $wk_jq('#mass_delete_butn').click(function(e){
            var flag =0;
            $wk_jq('.mpcheckbox').each(function(){
                if (this.checked == true){
                    flag =1;
                }
            });
            if (flag == 0){
                alert("<?php echo $helper->__(' No Checkbox is checked ') ?>");
                return false;
            }
            else{
                var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
                if(dicisionapp==true){
                    $wk_jq('#form-customer-product-new').submit();
                }else{
                    return false;
                }
            }
        });

        $wk_jq('#mpselecctall').click(function(event) {
            if(this.checked) {
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = true;      
                });
            }else{
                $wk_jq('.mpcheckbox').each(function() {
                    this.checked = false;           
                });         
            }
        });

        $wk_jq('.mp_delete').click(function(){
            var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
            var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
            if(dicisionapp==true)
                window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/delete/') ?>".concat("id/",id);
        });
    })($wk_jq);
    </script>
    <?php 
}else{
    echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>

if(typeof jQuery==“未定义”){
write(unescape(“%3Cscript src=”//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'type='text/javascript'%3E%3C/script%3E”);
}


请参考以下管理网格的URL:

我不确定,但这可能对你有帮助。请尝试以下前端:

步骤1:在编辑图像上生成onclick事件并调用javascript函数

eg :  onclick="updateField(this, '. $product_id .'); return false";
第2步:创建javascript函数,该函数已在单击图像时定义

<?php $url='Mage::getUrl('module_name/index/updateField/');' ?>
<script type="text/javascript">

function updateField(image, product_id)
{
    new Ajax.Request('<?php echo $url ?>', {
        method: 'post',
        parameters: { id: fieldId, field: $(button).previous('input').getValue() }
    });
}
</script>

这是相关的前端,你能告诉我我需要做什么吗?我更新了myproductlist.phtml中的第1步和第2步代码。我在“app/code/local/extension name/module name/controllers/shipping.php”中使用了第三步代码,但它不起作用。请检查:和:我在上述代码中从第12行添加到了第21行,但这并没有保存数量。如果我点击更新按钮,我会收到消息“产品已删除DHI,更新数量仅适用于第一个产品,请帮助我找到解决方案。”
<?php $url='Mage::getUrl('module_name/index/updateField/');' ?>
<script type="text/javascript">

function updateField(image, product_id)
{
    new Ajax.Request('<?php echo $url ?>', {
        method: 'post',
        parameters: { id: fieldId, field: $(button).previous('input').getValue() }
    });
}
</script>
public function updateFieldAction()
{
    $fieldId = (int) $this->getRequest()->getParam('id');
    $field = $this->getRequest()->getParam('field');
    if ($fieldId) {
        $model = Mage::getModel('modulename/model')->load($fieldId);
        $model->setField($field);
        $model->save();
    }
}