Magento Lowest Group Product Price Including Tier Prices

created August 17, 2015, last updated August 17, 2015.

.
closeThis post was last updated 2 years 5 months ago, some of the information contained here may no longer be actual and any referenced software versions may have been updated!

In Magento you can get price data for a product with $this->getPriceHtml($_product, true). The boolean true also returns information for the lowest price of the product. For configurable and simple products this will give you the lowest price including tier prices. For grouped products however it will give you the lowest unit price of the associated simple products.

If you want to show your grouped product lowest price including tier prices you need to modify price.phtml in app/design/frontend/yourtheme/default/template/catalog/product

If you edit price.phtml and scroll to the bottom you will see the logic for grouped products and the getDisplayMinimalPrice html. Add the code below just above the line with $showMinPrice = $this->getDisplayMinimalPrice();

This will get all the prices associated with the grouped product and set the lowest to be displayed as the miminal or “starting as” price. You can see this working here http://dev.gaiterjones.com/magento/catalogsearch/result/?q=1114 where the starting price is 99 – the lowest tier price. Without this modification the starting price is shown as the lowest unit price.

			// get lowest price from tiers

			$_groupedProductChildPrices=array();

			// get child products of grouped product
			//
			$_childProductIds = $_product->getTypeInstance()->getChildrenIds($_product->getId());

			foreach ($_childProductIds as $_ids) {

				foreach ($_ids as $_id) {

					$_childProduct = Mage::getModel('catalog/product')->load($_id);

					// get all associated group product pricing, including tier prices
					$_groupedProductChildPrices[] = $_childProduct['price'];

						if($_childProduct->getTierPrice() != NULL) {
							foreach($_childProduct->getTierPrice() as $tier){
								$_groupedProductChildPrices[]= $tier['price'];
							}
						}

				}
			}

			// set lowest price and reset minimal price variables
			//
			$_lowestGroupProductPrice=min($_groupedProductChildPrices);

			$_minimalPriceValue = $_store->roundPrice($_store->convertPrice($_lowestGroupProductPrice));
			$_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);

Comments