Try the Demo

Magento Forum

   
[Gelöst] Den geringsten Staffelpreis eines konfigurierbaren Produkts bekommen
 
JoernBernd
Member
 
Total Posts:  46
Joined:  2011-11-17
 

Hallo zusammen,

ich habe ein konfigurierbares Produkt mit Staffelpreisen.
Die Staffelpreise bekomme ich mit

$tierprices Mage::getModel('Bundle/Product_Price')->getTierPrice("",$_product);
.
Für Produkt A bzw. Produkt B erhalte ich mit
print_r($tierprices);
folgende Ausgaben:

Produkt A:
Array (
[0] => Array (
[price_id] => 1088
[website_id] => 0
[all_groups] => 1
[cust_group] => 32000
[price_qty] => 30.0000
[price] => 3.6000
[website_price] => 3.6000
)
[1] => Array (
[price_id] => 1087
[website_id] => 0
[all_groups] => 1
[cust_group] => 32000
[price_qty] => 5.0000
[price] => 4.0000
[website_price] => 4.0000
)
)

Produkt B:
Array (
[0] => Array (
[price_id] => 2939
[website_id] => 0
[all_groups] =>
[cust_group] => 32000
[price_qty] => 5.0000
[price] => 42.5000
[website_price] => 42.5000
)
[1] => Array (
[price_id] => 2917
[website_id] => 0
[all_groups] => 1
[cust_group] => 32000
[price_qty] => 10.0000
[price] => 39.5000
[website_price] => 39.5000
)
)

Ich möchte gerne von Produkt A bzw. B immer den geringsten “website_price” bekommen. Für Produkt A wäre das 3.6000 für Produkt B entsprechend 39.5000

Wie mache ich das?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rico_Neitzel
Magento Team
 
Avatar
Total Posts:  857
Joined:  2007-09-05
Würzburg, Germany
 

Du kannst eine array-filterfunktion nutzen, um nach dem geringsten preis zu sortieren und anschließend das erste bzw. letzte element vom array ziehen und ausgeben.

Liebe Grüße
Rico

 Signature 

Corporate: buro71a.de
Private: riconeitzel.de

Hinweis: Kein Support per PM, ICQ oder E-Mail, bitte nutzt das Forum!

Notice: No support via PM, ICQ or email. Please take a look at the forums

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoernBernd
Member
 
Total Posts:  46
Joined:  2011-11-17
 

Hallo Rico,

vielen Dank für deine Antwort:

Du kannst eine array-filterfunktion nutzen

Und da liegt genau mein Problem. Ich möchte wissen, wie man das Array filtert wink.

 
Magento Community Magento Community
Magento Community
Magento Community
 
JoernBernd
Member
 
Total Posts:  46
Joined:  2011-11-17
 

Ich hab´s jetzt so gemacht:

$tierprices Mage::getModel('Bundle/Product_Price')->getTierPrice(""$_product);
foreach (
$tierprices as $prices{
    $sort_array[] 
$prices["website_price"];
}
array_multisort
($sort_array$tierprices);
ksort($sort_array);
$first = (!empty($sort_array) ? $sort_array[0] '');
echo 
'<div class="lowest-tierprice"><span>'.$this->__('already from').'</span> <strong>'.$_coreHelper->currency($firsttruefalse).'</strong></div>';
Es geht bestimmt auch schöner, funktioniert aber wink.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top