Skip to content

Commit

Permalink
NTR: remove customField from deliveries for SW 6.6.7.0 (#865)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik authored Oct 16, 2024
1 parent c046b5c commit 9118c0f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
36 changes: 1 addition & 35 deletions src/Components/ShipmentManager/ShipmentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
use Kiener\MolliePayments\Service\MollieApi\OrderDeliveryExtractor;
use Kiener\MolliePayments\Service\MollieApi\OrderItemsExtractor;
use Kiener\MolliePayments\Service\MollieApi\ShipmentInterface;
use Kiener\MolliePayments\Service\OrderDeliveryService;
use Kiener\MolliePayments\Service\OrderService;
use Kiener\MolliePayments\Service\TrackingInfoStructFactory;
use Kiener\MolliePayments\Service\Transition\DeliveryTransitionServiceInterface;
use Kiener\MolliePayments\Struct\Order\OrderAttributes;
use Kiener\MolliePayments\Struct\OrderLineItemEntity\OrderLineItemEntityAttributes;
use Shopware\Core\Checkout\Cart\LineItem\LineItem;
use Shopware\Core\Checkout\Order\Aggregate\OrderDelivery\OrderDeliveryCollection;
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemCollection;
use Shopware\Core\Checkout\Order\Aggregate\OrderLineItem\OrderLineItemEntity;
use Shopware\Core\Checkout\Order\OrderEntity;
Expand All @@ -47,10 +45,6 @@ class ShipmentManager implements ShipmentManagerInterface
*/
private $shipmentService;

/**
* @var OrderDeliveryService
*/
private $orderDeliveryService;

/**
* @var OrderService
Expand All @@ -76,18 +70,16 @@ class ShipmentManager implements ShipmentManagerInterface
* @param DeliveryTransitionServiceInterface $deliveryTransitionService
* @param Order $mollieApiOrderService
* @param ShipmentInterface $shipmentService
* @param OrderDeliveryService $orderDeliveryService
* @param OrderService $orderService
* @param OrderDeliveryExtractor $orderDataExtractor
* @param OrderItemsExtractor $orderItemsExtractor
* @param TrackingInfoStructFactory $trackingFactory
*/
public function __construct(DeliveryTransitionServiceInterface $deliveryTransitionService, Order $mollieApiOrderService, ShipmentInterface $shipmentService, OrderDeliveryService $orderDeliveryService, OrderService $orderService, OrderDeliveryExtractor $orderDataExtractor, OrderItemsExtractor $orderItemsExtractor, TrackingInfoStructFactory $trackingFactory)
public function __construct(DeliveryTransitionServiceInterface $deliveryTransitionService, Order $mollieApiOrderService, ShipmentInterface $shipmentService, OrderService $orderService, OrderDeliveryExtractor $orderDataExtractor, OrderItemsExtractor $orderItemsExtractor, TrackingInfoStructFactory $trackingFactory)
{
$this->deliveryTransitionService = $deliveryTransitionService;
$this->mollieApiOrderService = $mollieApiOrderService;
$this->shipmentService = $shipmentService;
$this->orderDeliveryService = $orderDeliveryService;
$this->orderService = $orderService;
$this->orderDataExtractor = $orderDataExtractor;
$this->orderItemsExtractor = $orderItemsExtractor;
Expand Down Expand Up @@ -191,7 +183,6 @@ public function shipOrder(OrderEntity $order, ?TrackingData $tracking, array $sh

$this->transitionOrder($order, $mollieOrderId, $context);

$this->markDeliveryCustomFields($order, $context);

return $shipment;
}
Expand Down Expand Up @@ -234,8 +225,6 @@ public function shipOrderRest(OrderEntity $order, ?TrackingData $tracking, Conte

$this->transitionOrder($order, $mollieOrderId, $context);

$this->markDeliveryCustomFields($order, $context);

return $shipment;
}

Expand Down Expand Up @@ -301,7 +290,6 @@ public function shipItem(OrderEntity $order, string $itemIdentifier, int $quanti

$this->transitionOrder($order, $mollieOrderId, $context);

$this->markDeliveryCustomFields($order, $context);

return $shipment;
}
Expand All @@ -328,28 +316,6 @@ private function transitionOrder(OrderEntity $order, string $mollieOrderId, Cont
}
}

/**
* @param OrderEntity $order
* @param Context $context
* @return void
*/
private function markDeliveryCustomFields(OrderEntity $order, Context $context)
{
$deliveries = $order->getDeliveries();

if (!$deliveries instanceof OrderDeliveryCollection) {
return;
}

foreach ($deliveries as $delivery) {
$values = [
CustomFieldsInterface::DELIVERY_SHIPPED => true
];

$this->orderDeliveryService->updateCustomFields($delivery, $values, $context);
}
}

/**
* Try to find lineItems matching the $itemIdentifier. Shopware does not have a unique human-readable identifier for
* order line items, so we have to check for several fields, like product number or the mollie order line id.
Expand Down
1 change: 0 additions & 1 deletion src/Resources/config/services/facades.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<argument type="service" id="Kiener\MolliePayments\Service\Transition\DeliveryTransitionService"/>
<argument type="service" id="Kiener\MolliePayments\Service\MollieApi\Order"/>
<argument type="service" id="Kiener\MolliePayments\Service\MollieApi\Shipment"/>
<argument type="service" id="Kiener\MolliePayments\Service\OrderDeliveryService"/>
<argument type="service" id="Kiener\MolliePayments\Service\OrderService"/>
<argument type="service" id="Kiener\MolliePayments\Service\MollieApi\OrderDeliveryExtractor"/>
<argument type="service" id="Kiener\MolliePayments\Service\MollieApi\OrderItemsExtractor"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ public function setUp(): void

$deliveryTransitionService = $this->createMock(DeliveryTransitionService::class);
$mollieApiOrderService = $this->getMockBuilder(Order::class)->disableOriginalConstructor()->getMock();
$orderDeliveryService = $this->getMockBuilder(OrderDeliveryService::class)->disableOriginalConstructor()->getMock();
$orderService = $this->getMockBuilder(OrderService::class)->disableOriginalConstructor()->getMock();
$deliveryExtractor = new OrderDeliveryExtractor(new NullLogger());

$this->shipmentManager = new ShipmentManager(
$deliveryTransitionService,
$mollieApiOrderService,
$this->fakeShipmentService,
$orderDeliveryService,
$orderService,
$deliveryExtractor,
new OrderItemsExtractor(),
Expand Down

0 comments on commit 9118c0f

Please sign in to comment.