Skip to content

Commit

Permalink
Merge pull request #892 from solverat/fix_product_extractor
Browse files Browse the repository at this point in the history
Use Price Calculator Interface in ProductExtractor
  • Loading branch information
dpfaffenbauer authored Mar 22, 2019
2 parents 40b52e9 + 5211dd8 commit dd02d41
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/CoreShop/Component/Core/Tracking/Extractor/ProductExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
use CoreShop\Component\Core\Context\ShopperContextInterface;
use CoreShop\Component\Core\Model\CategoryInterface;
use CoreShop\Component\Core\Model\ProductInterface;
use CoreShop\Component\Core\Product\TaxedProductPriceCalculator;
use CoreShop\Component\Core\Product\TaxedProductPriceCalculatorInterface;
use CoreShop\Component\Order\Model\PurchasableInterface;
use CoreShop\Component\Tracking\Extractor\TrackingExtractorInterface;

class ProductExtractor implements TrackingExtractorInterface
{
/**
* @var TaxedProductPriceCalculator
* @var TaxedProductPriceCalculatorInterface
*/
private $taxedPurchasablePriceCalculator;

Expand All @@ -32,11 +32,11 @@ class ProductExtractor implements TrackingExtractorInterface
private $shopperContext;

/**
* @param TaxedProductPriceCalculator $taxedPurchasablePriceCalculator
* @param ShopperContextInterface $shopperContext
* @param TaxedProductPriceCalculatorInterface $taxedPurchasablePriceCalculator
* @param ShopperContextInterface $shopperContext
*/
public function __construct(
TaxedProductPriceCalculator $taxedPurchasablePriceCalculator,
TaxedProductPriceCalculatorInterface $taxedPurchasablePriceCalculator,
ShopperContextInterface $shopperContext
) {
$this->taxedPurchasablePriceCalculator = $taxedPurchasablePriceCalculator;
Expand Down Expand Up @@ -66,15 +66,15 @@ public function updateMetadata($object, $data = []): array
* @var $object PurchasableInterface
*/
return array_merge($data, [
'id' => $object->getId(),
'name' => $object->getName(),
'category' => (is_array($categories) && count($categories) > 0) ? $categories[0]->getName() : '',
'sku' => $object instanceof ProductInterface ? $object->getSku() : '',
'price' => $this->taxedPurchasablePriceCalculator->getPrice($object, $this->shopperContext->getContext()) / 100,
'currency' => $this->shopperContext->getCurrency()->getIsoCode(),
'id' => $object->getId(),
'name' => $object->getName(),
'category' => (is_array($categories) && count($categories) > 0) ? $categories[0]->getName() : '',
'sku' => $object instanceof ProductInterface ? $object->getSku() : '',
'price' => $this->taxedPurchasablePriceCalculator->getPrice($object, $this->shopperContext->getContext()) / 100,
'currency' => $this->shopperContext->getCurrency()->getIsoCode(),
'categories' => array_map(function (CategoryInterface $category) {
return [
'id' => $category->getId(),
'id' => $category->getId(),
'name' => $category->getName(),
];
}, is_array($categories) ? $categories : []),
Expand Down

0 comments on commit dd02d41

Please sign in to comment.