Skip to content

Commit

Permalink
add helper to get tax entity by value
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Jun 26, 2023
1 parent 66be91e commit e8b7b6a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/Utils/SalesChannelUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class SalesChannelUtils
public function __construct(EntityRepository $salesChannelRepository, EntityRepository $snippetSetRepository, EntityRepository $taxRepository, EntityRepository $countryRepository, EntityRepository $languageRepository, EntityRepository $currencyRepository)
{
$this->salesChannelRepository = $salesChannelRepository;
$this->snippetSetRepository = $snippetSetRepository;
$this->taxRepository = $taxRepository;
$this->countryRepository = $countryRepository;
$this->languageRepository = $languageRepository;
$this->currencyRepository = $currencyRepository;
$this->snippetSetRepository = $snippetSetRepository;
$this->taxRepository = $taxRepository;
$this->countryRepository = $countryRepository;
$this->languageRepository = $languageRepository;
$this->currencyRepository = $currencyRepository;
}

public function getStorefrontSalesChannel(): ?SalesChannelEntity
Expand Down Expand Up @@ -104,4 +104,20 @@ public function getTax19(): ?TaxEntity
->search($criteria, Context::createDefaultContext())
->first();
}

/**
* @param int $taxValue
* @return TaxEntity|null
*/
public function getTax(int $taxValue): ?TaxEntity
{
$criteria = (new Criteria())
->addFilter(new EqualsFilter('taxRate', $taxValue))
->setLimit(1);

return $this->taxRepository
->search($criteria, Context::createDefaultContext())
->first();
}

}

0 comments on commit e8b7b6a

Please sign in to comment.