1
1
<?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
2
7
3
8
namespace Magento \Bundle \Model \Sales \Order ;
4
9
5
10
use Magento \Bundle \Model \Sales \Order \Shipment \BundleShipmentTypeValidator ;
6
11
use \Laminas \Validator \ValidatorInterface ;
7
12
use Magento \Sales \Model \Order \Shipment ;
8
13
14
+ /**
15
+ * Validate if requested order items can be shipped according to bundle product shipment type
16
+ */
9
17
class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements ValidatorInterface
10
18
{
11
19
/**
@@ -14,6 +22,8 @@ class BundleOrderTypeValidator extends BundleShipmentTypeValidator implements Va
14
22
private array $ messages = [];
15
23
16
24
/**
25
+ * Validates shipment items based on order item properties
26
+ *
17
27
* @param Shipment $value
18
28
* @return bool
19
29
* @throws \Magento\Framework\Exception\NoSuchEntityException
@@ -24,7 +34,9 @@ public function isValid($value): bool
24
34
foreach ($ value ->getOrder ()->getAllItems () as $ orderItem ) {
25
35
foreach ($ value ->getItems () as $ shipmentItem ) {
26
36
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
+ }
28
40
}
29
41
}
30
42
}
@@ -33,6 +45,8 @@ public function isValid($value): bool
33
45
}
34
46
35
47
/**
48
+ * Returns validation messages
49
+ *
36
50
* @return array|string[]
37
51
*/
38
52
public function getMessages (): array
0 commit comments