diff --git a/CHANGELOG.md b/CHANGELOG.md index 0be5cb0..96e0612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] +### Added +- Add new helper method to load a TaxEntity by its value. + ## [2.2.1] - 2023-05-26 ### Fixed - Restored compatibility for Shopware 6.4 by removing typehints for **EntityRepository** in util classes. diff --git a/src/Utils/SalesChannelUtils.php b/src/Utils/SalesChannelUtils.php index 83e22e2..8088d64 100644 --- a/src/Utils/SalesChannelUtils.php +++ b/src/Utils/SalesChannelUtils.php @@ -104,4 +104,15 @@ public function getTax19(): ?TaxEntity ->search($criteria, Context::createDefaultContext()) ->first(); } + + public function getTax(int $taxValue): ?TaxEntity + { + $criteria = (new Criteria()) + ->addFilter(new EqualsFilter('taxRate', $taxValue)) + ->setLimit(1); + + return $this->taxRepository + ->search($criteria, Context::createDefaultContext()) + ->first(); + } }