What would be a good way of retrieving the lowest and highest possible prices for a given configurable product – based on its availble options?
For example a t-shirt comes in the following sizes and prices:
Small - $10
Medium - $20
Large - $30
I want to get an array like so:
array(10, 30)
My best idea so far is load the configurable product type instance and use getUsedProducts
, then create an array of prices, sort and slice.
That should work, however this needs to be run on the product list template so it needs to be semi efficient.
Any others out there faced this problem before?
EDIT – that wont work since i want the configurable pricing value i.e. the additive price magento puts on top of the configurable product price
Best Answer
Try this approach. use the config array that the attribute dropdowns use to change the price of the configurable product. Let's assume that
$productId
is the ID of the configurable product.