Get the tier prices of an associated product in Magento
I'm using Magento 1.4.1.1
How can I get the tier prices of the associated product?
I'm only getting the price of the configurable product. I'll site ang example:
开发者_运维百科Example: Product Apple is a configurable product thas has tier prices, $10,$20,$30. Product Apple has also an associated product like Green Apple, it has tier prices, $15,$20,$30.
My question here, is how can I get the value of my Associated products.
Thanks and Have a good Day!
Try getting the associated products collection and iterating through them, like so:
// this just checks to ensure it's a configurable product;
// if you know the product is configurable already, you don't need
// this step
if ($product->getTypeId() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE){
$associated_products = $product->getTypeInstance()->getUsedProductCollection($product);
foreach ($associated_products as $associated_product){
//print_r( $associated_product->getTierPrice() );
}
}
Edit: just a quick note. This code assumes Magento 1.6. I don't remember if 1.4 had the TYPE_CONFIGURABLE
class constant, but I believe it did. If not, this code may require adjustments for older versions of Magento.
精彩评论