diff --git a/src/Resources/config/services/services.xml b/src/Resources/config/services/services.xml index 0a77f60ad..a66278967 100644 --- a/src/Resources/config/services/services.xml +++ b/src/Resources/config/services/services.xml @@ -79,6 +79,7 @@ + %shopware.stock.enable_stock_management% diff --git a/src/Service/Stock/StockManager.php b/src/Service/Stock/StockManager.php index c7e0673b1..dcc7b2dff 100644 --- a/src/Service/Stock/StockManager.php +++ b/src/Service/Stock/StockManager.php @@ -8,6 +8,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity; use Shopware\Core\Defaults; use Shopware\Core\Framework\DataAbstractionLayer\Doctrine\RetryableQuery; +use Shopware\Core\Framework\Feature; use Shopware\Core\Framework\Uuid\Uuid; class StockManager implements StockManagerInterface @@ -17,13 +18,20 @@ class StockManager implements StockManagerInterface */ private $connection; + /** + * @var bool + */ + private $enableStockManagement; + /** * @param Connection $connection + * @param bool $enableStockManagement */ - public function __construct(Connection $connection) + public function __construct(Connection $connection, bool $enableStockManagement) { $this->connection = $connection; + $this->enableStockManagement = $enableStockManagement; } /** @@ -35,6 +43,10 @@ public function __construct(Connection $connection) */ public function increaseStock(OrderLineItemEntity $lineItem, int $quantity, string $mollieRefundID): void { + if ($this->isEnabled() === false) { + return; + } + if ($lineItem->getPayload() === null) { return; } @@ -59,4 +71,8 @@ public function increaseStock(OrderLineItemEntity $lineItem, int $quantity, stri ] ); } + private function isEnabled(): bool + { + return $this->enableStockManagement && Feature::isActive('STOCK_HANDLING'); + } }