在产品详细信息页面中,它显示了折扣百分比。当我打开列表页面时,无法显示可配置产品的百分比。
请给我解决方案。
我为此使用了以下代码,但不适用于可配置产品。
<div class="discount-p">
    <?php
    if($_product->getTypeId() == "simple") {
        $simplePrice = $_product->getPrice();
        } else {
            $_children = $_product->getTypeInstance()->getUsedProducts($_product);
            foreach ($_children as $child){
            $simplePrice = $child->getPrice();
            break;
        }
    }
    $_finalPrice =$_product->getFinalPrice();
    $_price = $simplePrice;
    if($_finalPrice < $_price) {
    $_savingPercent = 100 - round(($_finalPrice / $_price)*100);
    echo '('. $_savingPercent . '%off)';
    }
    ?>
</div>
                  嗨,你知道了吗?
                
                
                  
                    —
                    Ask Bytes,
                    
                  
                
              
                  @Ask字节仍不
                
                
                  
                    —
                    米拉
                    
                  
                
              
                  @AskBytes让我知道是否仍然无法使用。我测试了我的代码,它可以正常工作。
                
                
                  
                    —
                    罗汉哈帕尼
                    
                  
                
              
