cancel
Showing results for 
Search instead for 
Did you mean: 

Funzione getSelectionFinalTotalPrice, Bundle aggiornamento prezzo

Funzione getSelectionFinalTotalPrice, Bundle aggiornamento prezzo

Salve e buonasera,

ho aggiornato in local il model Price.phtml che si occupa di gestire i prezzi dei prodotti bundle.

La mia esigenza è quello di aggiungere un prezzo al normale prezzo del bundle dimamico basandomi su un attributo custom (supplementoprezzo)

Questa è la funzione interessata:

public function getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty,
                                            $multiplyQty = true, $takeTierPrice = true)
{

// recupero il valore del supplemento $attribute = $bundleProduct->getResource()->getAttribute('supplementoprezzo'); $supplementoprezzo = $attribute_value = $attribute ->getFrontend()->getValue($bundleProduct); if (is_null($selectionQty)) { $selectionQty = $selectionProduct->getSelectionQty(); } if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) { $price = $selectionProduct->getFinalPrice($takeTierPrice ? $selectionQty : 1); } else { if ($selectionProduct->getSelectionPriceType()) { // percent $product = clone $bundleProduct; $product->setFinalPrice($this->getPrice($product)); Mage::dispatchEvent( 'catalog_product_get_final_price', array('product' => $product, 'qty' => $bundleQty) ); $price = ($product->getData('final_price')) * ($selectionProduct->getSelectionPriceValue() / 100); } else { // fixed $price = $selectionProduct->getSelectionPriceValue(); } } $price = $this->getLowestPrice($bundleProduct, $price, $bundleQty); if ($multiplyQty) { $price *= $selectionQty; }
// sommo il supplemento al prezzo $price += $supplementoprezzo; return $price; }

 Le ultime due righe sono le righe interessate: la variabile $supplementoprezzo è un numero float. 

Il problema (e la cosa strana) è che se inserisco un numero:

    $price += 2.50;
    return $price;

tutto funziona perfettamente.

Invece sommando la variabile (che pure è un numero)

$price += $supplementoprezzo;
return $price;

non mi aggiorna il prezzo finale del bundle.

Ho provato con vari casting per la variabile (float, floatval number_format, etc).... niente.

Qualche suggerimento?

 

Grazie,

Saverio