Php 如何在magento网店的首页设置不同的价格

Php 如何在magento网店的首页设置不同的价格,php,magento,Php,Magento,我在一家Magento网店工作,因为这是一家黄金和白银网店,所以它需要有相应的价格。将项目添加到购物车时,它会计算值,但在frontpage和类别页面上,它有一个设置值 作为活动,我们使用: <catalog_product_collection_load_after> <observers> <webshop> <class>webshope/observer</class>

我在一家Magento网店工作,因为这是一家黄金和白银网店,所以它需要有相应的价格。将项目添加到购物车时,它会计算值,但在frontpage和类别页面上,它有一个设置值

作为活动,我们使用:

<catalog_product_collection_load_after>
    <observers>
        <webshop>
            <class>webshope/observer</class>
            <method>updateCatalogPrice</method>
        </webshop>
    </observers>
</catalog_product_collection_load_after>
这计算了价格:

public function CalculatePrice($product) {

    if ($product->dynamicprice == '243') { //dynamic price

        $xml=simplexml_load_file('../MagentoAssets/ResponsivePrices/test.xml');

        $prijsGold = (float)$xml->Gold;
        $prijsSilver = (float)$xml->Silver;

        if($product->grondstof == '241'){ //gold    
            $weight = $product->weight;         
            $result = $weight*$prijsGold; 
            $result = sprintf("%.2f", $result);
        }

        elseif($product->grondstof == '240'){ //silver 
            $weight = $product->weight;
            $result = $weight*$prijsSilver;
            $result = sprintf("%.2f", $result);
        }

        return $result;

    }
    else{ //manual price
        return $product->price;
    }   
}
由于某些原因,
没有给出动态值和“grondstof”(荷兰语表示该项所用的资源) 所以我的问题是:我如何让这个事件给出动态值和另一个,或者让一个事件可以实现相同的结果?

这对我有用这对我有用
public function CalculatePrice($product) {

    if ($product->dynamicprice == '243') { //dynamic price

        $xml=simplexml_load_file('../MagentoAssets/ResponsivePrices/test.xml');

        $prijsGold = (float)$xml->Gold;
        $prijsSilver = (float)$xml->Silver;

        if($product->grondstof == '241'){ //gold    
            $weight = $product->weight;         
            $result = $weight*$prijsGold; 
            $result = sprintf("%.2f", $result);
        }

        elseif($product->grondstof == '240'){ //silver 
            $weight = $product->weight;
            $result = $weight*$prijsSilver;
            $result = sprintf("%.2f", $result);
        }

        return $result;

    }
    else{ //manual price
        return $product->price;
    }   
}