protected function extractVariantData(VariantInterface $variant, array &$variants) { $sellPrice = $variant->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); $key = $this->getVariantOptionsKey($variant); $variants[$key] = ['id' => $variant->getId(), 'finalPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getFinalGrossAmount(), $baseCurrency), 'sellPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getGrossAmount(), $baseCurrency), 'discountPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getDiscountedGrossAmount(), $baseCurrency), 'stock' => $variant->getStock(), 'symbol' => $variant->getSymbol(), 'options' => $this->getVariantOptions($variant)]; }
/** * Returns the attribute's data * * @param ProductAttributeInterface $productAttribute * * @return array */ protected function getAttributeData(ProductAttributeInterface $productAttribute) { $sellPrice = $productAttribute->getSellPrice(); $baseCurrency = $sellPrice->getCurrency(); return ['id' => $productAttribute->getId(), 'finalPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getFinalGrossAmount(), $baseCurrency), 'sellPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getGrossAmount(), $baseCurrency), 'discountPriceGross' => $this->currencyHelper->convertAndFormat($sellPrice->getDiscountedGrossAmount(), $baseCurrency), 'stock' => $productAttribute->getStock(), 'symbol' => $productAttribute->getSymbol()]; }
/** * Formats the amount * * @param int|float $price * @param null|string $baseCurrency * @param null|string $targetCurrency * @param null|string $locale * * @return string */ public function formatPrice($price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) { return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale); }