Return the cheapest variation of the product (or itself if none).

@param ProductInterface $product

@return ProductInterface
517432
public function getCheapestEnabledVariation(ProductInterface $product)
    {
        if (!$this->productPool->getProvider($product)->hasVariations($product)) {
            return $product;
        }

        return $this->productPool->getProvider($product)->getCheapestEnabledVariation($product);
    }
906473
public function fetchFor($product)
    {
        $product = $this->getScopedProduct($product);

        if ($product->getVisibility() == \Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE &&
            $product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
        ) {
            $parentId = $this->getFirstParentId($product);
            if (isset($parentId)) {
                /** @var \Magento\Catalog\Model\Product $parentProduct */
                $parentProduct = $this->productRepository->getById($parentId, false, $product->getStoreId());
                return $parentProduct->getProductUrl();
            }
        }
        return $product->getProductUrl();
    }
1150677
public function setProduct(ProductInterface $product)
    {
        $this->productId = $product->getId();
        $this->product = $product;
    }
809028
public function getProduct()
    {
        if ($this->product) {
            return $this->product;
        }

        if ($this->subject && $product = $this->subject->getProduct()) {
            $this->product = $product;

            return $product;
        }

        $product_id = $this->getRequest()->get('product_id') ?: $this->getRequest()->get('productId');
        if ($product_id) {
            $product = $this->getConfigurationPool()->getContainer()->get('sylius.repository.product')->find($product_id);
            if (!$product) {
                throw new \Exception(sprintf('Unable to find Product with id : %s', $product_id));
            }
            $this->product = $product;

            return $product;
        }

        return null;
    }
474158
public function product(Product $product): Money
    {
        if ($product->quantity >= $this->quantity) {
            return $this->rate->product($product);
        }

        return new Money(0, $product->price->getCurrency());
    }
725046
public function single($product)
    {
        $entry = new Entry($product);

        $entry
            ->conditionalField('id', function () {
                return Subbly::api('subbly.user')->hasAccess('subbly.backend.auth');
            })

            ->field('position')
            ->field('name')
            ->field('description')
            ->field('sku')
            ->field('slug')
            ->field('status')
            ->field('price')
            ->field('sale_price')
            ->field('quantity')
            ->field('locale')

            ->relationshipField('images', 'Subbly\\Presenter\\V1\\ProductImagePresenter')
            ->relationshipField('options', 'Subbly\\Presenter\\V1\\ProductOptionPresenter')
            ->relationshipField('categories', 'Subbly\\Presenter\\V1\\CategoryPresenter')

            ->dateField('created_at')
            ->dateField('updated_at')
        ;

        return $entry->toArray();
    }
176530
public function getData(ProductInterface $product)
    {
        $productItemData = [
            'id'          => $product->getId(),
            'sku'         => $product->getSku(),
            'name'        => $product->getName(),
            'price'       => $this->getProductPrice($product),
            'image'       => $this->getImageUrl($product),
            'score'       => $product->getDocumentScore(),
            'is_in_stock' => $this->isInStockProduct($product),
        ];

        return $productItemData;
    }
1187358
public function getProductPrice(ProductInterface $product, CurrencyInterface $currency, $vat = false)
    {
        return $this->productPool->getProvider($product)->calculatePrice($product, $currency, $vat, 1);
    }
763534
private function retrieveProductById($productId)
    {
        // Fetch product.
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException($productId);
        }

        return $product;
    }
1037192
public function subtotal(Product $product)
    {
        $subtotal = $this->money($product);

        if (! $product->freebie) {
            $value    = $this->value($product);
            $discount = $this->discount($product);
            $subtotal = $subtotal->add($value)->subtract($discount);
        }

        $delivery = $this->delivery($product);
        $subtotal = $subtotal->add($delivery);

        return $subtotal;
    }
1037447
private function getProductPrice(ProductInterface $product)
    {
        $price    = 0;
        $document = $this->getDocumentSource($product);

        if (isset($document['price'])) {
            foreach ($document['price'] as $currentPrice) {
                if ((int) $price['customer_group_id'] === GroupInterface::NOT_LOGGED_IN_ID) {
                    $price = (float) $currentPrice['price'];
                }
            }
        }

        return $price;
    }
1118431
public function total(Product $product)
    {
        $tax      = $this->tax($product);
        $subtotal = $this->subtotal($product);
        $total    = $subtotal->add($tax);

        return $total;
    }
888294
public function index($product)
    {
        if (is_numeric($product)) {
            $product = $this->product->get($product);
        }

        if (empty($product)) {
            return false;
        }

        $indexed = 0;
        $indexed += (int) $this->indexProduct($product);
        $indexed += (int) $this->indexProductTranslations($product);

        return $indexed > 0;
    }
823850
public function getPrice($product)
    {
        $normalPrice = parent::getPrice($product);
        if ($product->getData('discount') > 0) {
            return $normalPrice - $product->getDiscount();
        }

        return $normalPrice;
    }
864218
public static function generateProductVariantCode(ProductInterface $product, array $productOptions): CodeInterface
    {
        $productVariantCodeGenerator = new ProductVariantCodeGenerator();

        return $productVariantCodeGenerator->generate($product->getCode(), $productOptions);
    }
1299662
public function addProduct(\Sulu\Bundle\ProductBundle\Entity\ProductInterface $products)
    {
        $this->products[] = $products;

        return $this;
    }
204364
protected function getSelectedCombinationProduct(array $product)
    {
        $field_value_ids = array();

        if (!empty($product['default_field_values'])) {
            $field_value_ids = $product['default_field_values'];
        }

        $selected = $this->sku->selectCombination($product, $field_value_ids);
        $selected += $product;
        return $selected;
    }