MsrpPriceCalculator.php 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\MsrpGroupedProduct\Pricing;
  8. use Magento\Catalog\Api\Data\ProductInterface;
  9. use Magento\Catalog\Model\Product;
  10. use Magento\GroupedProduct\Model\Product\Type\Grouped;
  11. use Magento\Msrp\Pricing\MsrpPriceCalculatorInterface;
  12. /**
  13. * {@inheritdoc}. Provide information for a Grouped product.
  14. */
  15. class MsrpPriceCalculator implements MsrpPriceCalculatorInterface
  16. {
  17. /**
  18. * @inheritdoc
  19. */
  20. public function getMsrpPriceValue(ProductInterface $product): float
  21. {
  22. /** @var Product $product */
  23. if ($product->getTypeId() !== Grouped::TYPE_CODE) {
  24. return 0;
  25. }
  26. /** @var Grouped $groupedProduct */
  27. $groupedProduct = $product->getTypeInstance();
  28. return $groupedProduct->getChildrenMsrp($product);
  29. }
  30. }