1

I made the custom phtml and I have custom product collection. I just need to show the minimal price of associated simple product of grouped product.

Any help would be appreciated.

  • First get child IDS from this function getChildrenIds($parentId, $required = true) – Aditya Shah Apr 24 at 11:34
  • Magento\GroupedProduct\Model\Product\Type\Grouped – Aditya Shah Apr 24 at 11:34
0

You just need to add this code in your phtml file. Variable lowest price has the minimal price.

$lowestprice = 0; $count = 0;
if ($_product->getTypeId() == 'grouped') {

    $usedProds = $_product->getTypeInstance(true)->getAssociatedProducts($_product);
    foreach ($usedProds as $child) {
        if ($child->getId() != $_product->getId()) {
            if ($count == 0){
                $lowestprice = $child->getPrice();
            }

            if ($child->getPrice() < $lowestprice){
                $lowestprice = $child->getPrice();
            }
        }
      $count++;
    }
    $finalPrice = $lowestprice;
}

I hope this will help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.