Skip to content

Commit 779f089

Browse files
committed
ACP2E-1650:Create Shipment API
- added validation for create shipment API call when order contains bundle products
1 parent e71ee4b commit 779f089

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
27

38
namespace Magento\Bundle\Model\Sales\Order;
49

510
use Magento\Bundle\Model\Sales\Order\Shipment\BundleShipmentTypeValidator;
611
use \Laminas\Validator\ValidatorInterface;
712
use Magento\Sales\Model\Order\Shipment;
813

14+
/**
15+
* Validate if requested order items can be shipped according to bundle product shipment type
16+
*/
917
class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements ValidatorInterface
1018
{
1119
/**
@@ -14,6 +22,8 @@ class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements Va
1422
private array $messages = [];
1523

1624
/**
25+
* Validates shipment items based on order item properties
26+
*
1727
* @param Shipment $value
1828
* @return bool
1929
* @throws \Magento\Framework\Exception\NoSuchEntityException
@@ -24,7 +34,9 @@ public function isValid($value): bool
2434
foreach ($value->getOrder()->getAllItems() as $orderItem) {
2535
foreach ($value->getItems() as $shipmentItem) {
2636
if ($orderItem->getItemId() == $shipmentItem->getOrderItemId()) {
27-
$this->messages = array_merge($this->messages, $this->validate($orderItem));
37+
if ($result = $this->validate($orderItem)) {
38+
$this->messages[] = $result;
39+
}
2840
}
2941
}
3042
}
@@ -33,6 +45,8 @@ public function isValid($value): bool
3345
}
3446

3547
/**
48+
* Returns validation messages
49+
*
3650
* @return array|string[]
3751
*/
3852
public function getMessages(): array

lib/internal/Magento/Framework/Model/AbstractModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ protected function _createValidatorBeforeSave()
779779
/**
780780
* @return ValidatorChain
781781
*/
782-
protected function getValidator(): ValidatorChain
782+
private function getValidator(): ValidatorChain
783783
{
784784
return \Magento\Framework\App\ObjectManager::getInstance()->create(ValidatorChain::class);
785785
}

0 commit comments

Comments
 (0)