首页 文章

在Magento前端创建一个层级价格表/网格

提问于
浏览
0

我试图弄清楚如何将Magento产品详细信息页面中的层定价格式化为网格/表格格式 . 例如,我想要一个数量行,价格行和折扣行 . 它大约5列 . 这可能吗?我们批量销售产品,因此这种布局很重要 . 如果有人可以直截了当地指出我,那将是很棒的 . 我是magento的新手,并且发现难以接受的定制方面 .

谢谢!

2 回答

  • 0

    我为tierprices.phtml制作了以下模板 .
    仅供我使用Magento 1.8.x

    <?php
    $_product = $this->getProduct();
    $_tierPrices = $this->getTierPrices();
    if (count($_tierPrices) > 0):
        $_data = array();
        $_prevQty = 0;
        $_counter = 0;
        $_tierPrices = array_reverse($_tierPrices);
        foreach ($_tierPrices as $_index => $_price){
            $_counter++;
            if($_price['price_qty']>$_prevQty){
                if($_counter == 1){
                    $label = $_price['price_qty'] . '+';
                } else {
                    $label = $this->__('%d or less',$_price['price_qty']);
                }
                $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price']);
                $_prevQty = $_price['price_qty'];
            } else {
                $label = $_price['price_qty'] . '-' . $_prevQty;
                $_data[] = array('prev'=>$_prevQty,'next'=>$_price['price_qty'],'label'=>$label,'price'=>$_price['formated_price']);
                $_prevQty = $_price['price_qty'];
            }
        }
        $_data = array_reverse($_data);
    ?>
        <table class="tiered-pricing">
            <tbody>
                <tr>
                    <th>Quantity</th>
                    <th>Price</th>
                </tr>
            <?php foreach ($_data as $_row): ?>
                <tr>
                    <td><?php echo $_row['label']; ?></td>
                    <td><?php echo $_row['price']; ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    <?php
    endif;
    ?>
    

    它生成分层定价数据的表格版本 .

  • 2

    以下URL将非常有用:

    http://stackoverflow.com/questions/9257924/magento-tier-sales-prices

    您还可以修改以下模板

    magento/app/design/frontend/default/your_theme/template/catalog/product/view/tierprices.phtml
    

    你可以在哪里循环 $_tierPrices 数组并生成html表元素

相关问题