boti
boti

Reputation: 677

Use Tierprices of other customergroup

i'm trying to get my pricing extension working but i'm stucking at the tierprices. If a visitor comes to my site i added a paramter to the cookie.

Example: http://www.foo.com/category/product.html?sidx=5

Now the visitor enters my site with the sidx parameter. Now the Observer: catalog_product_get_final_price sets the finalprice with the first tierprice of this Product of Customergroup 5.

The Customergroup of the visitor is still NOT LOGGED IN. Now i need the other tierprices of the Customergroup ID 5 without registering.

I have googled a lot to find a solution for that but i don't get the point.

Best Regards boti

Upvotes: 1

Views: 130

Answers (1)

Andrew
Andrew

Reputation: 12809

If you want to get the Tier prices for any product:

$product = Mage::getModel('catalog/product')->load(PRODUCT_ID_HERE);
$tierPrices = $product->getData('tier_price');

if (!is_array($tierPrices)) {
    $tierPrices = array();
}

$result = array();

foreach ($tierPrices as $tierPrice) {
   $row = array();
   $row['customer_group_id'] = (empty($tierPrice['all_groups']) ? $tierPrice['cust_group'] : 'all' );
   $row['website']           = ($tierPrice['website_id'] ? Mage::app()->getWebsite($tierPrice['website_id'])->getCode() : 'all');
   $row['qty']               = $tierPrice['price_qty'];
   $row['price']             = $tierPrice['price'];

   $result[] = $row;
}

// $result now has an array of all tier prices...
// looking for cust_group = 5 would be trivial:

foreach ($tierPrices as $tierPrice) {
    if($tierPrice['cust_group'] == 5) {
        return $tierPrice; // this is what you want..
    }
}

Upvotes: 1

Related Questions