Magento:Tier价格定制领域

时间:2014-01-16 13:17:31

标签: magento magento-1.8

我修改了层级定价的magento扩展,并在app-> design-> adminhtml-> default-> default-> catalog-> product-> edit->价格中添加了三个文本字段 - > tier.phtml文件。               来自三个新字段的数据成功插入到catalog_product_entity_tier_price表中。               数据在前端也可见。 但问题是层级盒子价格插入数据和字段不匹配

        <table>
          <thead>
            <tr class="headings">
              <th>Website</th>
              <th>Customer Group</th>
              <th>Qty</th>
              <th>Custom_field_1</th>
              <th>Custom_field_2</th>
              <th>Price</th>
              <th>Custom_field_3</th>
              <th>Action</th>
          </thead>
            </tr>

          <tr>
            <td>Showing Correct</td>
            <td>Showing Correct</td>
            <td>Showing Correct</td>
            <td>Showing Custom_field_2</td>
            <td>Showing Custom_field_3</td>
            <td>Showing Correct</td>
            <td>undefined</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        <p>&nbsp;</p>
       <p>&nbsp;</p>
        <b>And javascript code is</b> 
        <script type="text/javascript">

              var tierPriceRowTemplate = '<tr>'

            + ' <small class="nobr"><?php echo Mage::helper("catalog")->__("and above")?></small></td>'
            + '<td><input class="<?php echo $_htmlClass ?> Custom_field_1" type="text" name="<?php echo $_htmlName ?>[{{index}}][Custom_field_1]" value="{{Custom_field_1}}"  
              id="tier_price_row_{{index}}_Custom_field_1" /></td>'
            + '<td><input class="<?php echo $_htmlClass ?> Custom_field_2" type="text" name="<?php echo $_htmlName ?>[{{index}}][Custom_field_2]" value="{{Custom_field_2}}"       id="tier_price_row_{{index}}_Custom_field_2" /></td>'  
            + '<td><input class="<?php echo $_htmlClass ?> required-entry <?php echo $_priceValueValidation ?>" type="text" name="<?php echo $_htmlName ?>[{{index}}][price]" value="{{price}}"        id="tier_price_row_{{index}}_price" /></td>'
            + '<td><input class="<?php echo $_htmlClass ?> Custom_field_3" type="text" name="<?php echo $_htmlName ?>[{{index}}][Custom_field_3]" value="{{Custom_field_3}}"       id="tier_price_row_{{index}}_Custom_field_3"/></td>';


                var data = {
                    website_id: '<?php echo $this->getDefaultWebsite() ?>',
                    group: '<?php echo $this->getDefaultCustomerGroup() ?>',
                    qty: '',
                    Custom_field_1:'',
                    price: '',
                    Custom_field_2:'',
                    Custom_field_3:'',
                    readOnly: false,
                    index: this.itemsCount++
                };
                //alert(Custom_field_1);

                if(arguments.length >= 4) {

                    data.Custom_field_1 = arguments[4]

                    data.readOnly = arguments[5];
                    data.Custom_field_2      = arguments[7];
                    data.Custom_field_3     = arguments[8];
                }
                if (arguments.length == 5) {
                    data.readOnly = arguments[4];
                }



                $('tier_price_row_' + data.index + '_Custom_field_1').value    = data.Custom_field_1;
                $('tier_price_row_' + data.index + '_Custom_field_2').value    = data.Custom_field_2;
                $('tier_price_row_' + data.index + '_Custom_field_3').value    = data.Custom_field_3;


            </script>

1 个答案:

答案 0 :(得分:1)

解决问题:问题出在jquery代码中 请检查我编辑的代码

    if(arguments.length >=8) {
        data.website_id = arguments[0];
        data.group      = arguments[1];
        data.qty        = arguments[2];
        data.product_type = arguments[3]
        data.ourprice      = arguments[4];
        data.price      = arguments[5];
        data.links     = arguments[6];
        data.readOnly = arguments[7];
    }
    if (arguments.length == 9) {
        data.readOnly = arguments[8];
    }

    Element.insert($('<?php echo $_htmlId ?>_container'), {
        bottom : this.template.evaluate(data)
    });

    $('tier_price_row_' + data.index + '_cust_group').value = data.group;
    $('tier_price_row_' + data.index + '_website').value    = data.website_id;