Skip to content

Commit 8ac621e

Browse files
committed
ACP2E-1650:Create Shipment API
- validation is only triggered for specific api route
1 parent 53ad543 commit 8ac621e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/code/Magento/Bundle/Model/Sales/Order/BundleOrderTypeValidator.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements ValidatorInterface
1818
{
19+
private const SHIPMENT_API_ROUTE = '/v1/shipment/';
20+
1921
/**
2022
* @var array
2123
*/
@@ -31,6 +33,10 @@ class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements Va
3133
*/
3234
public function isValid($value): bool
3335
{
36+
if (false === $this->canValidate()) {
37+
return true;
38+
}
39+
3440
foreach ($value->getOrder()->getAllItems() as $orderItem) {
3541
foreach ($value->getItems() as $shipmentItem) {
3642
if ($orderItem->getItemId() == $shipmentItem->getOrderItemId()) {
@@ -53,4 +59,14 @@ public function getMessages(): array
5359
{
5460
return $this->messages;
5561
}
62+
63+
/**
64+
* @return bool
65+
*/
66+
private function canValidate(): bool
67+
{
68+
$url = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\Url::class);
69+
70+
return str_contains(strtolower($url->getCurrentUrl()), self::SHIPMENT_API_ROUTE);
71+
}
5672
}

0 commit comments

Comments
 (0)