File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed
view/frontend/templates/catalog/product/view/type/bundle/option Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \Bundle \ViewModel ;
9
9
10
- use Magento \CatalogInventory \ Model \ StockRegistry ;
10
+ use Magento \Framework \ Serialize \ Serializer \ Json ;
11
11
use Magento \Framework \View \Element \Block \ArgumentInterface ;
12
12
use Magento \Catalog \Block \Product \View as ProductView ;
13
13
14
14
/**
15
15
* ViewModel for Bundle Option Block
16
16
*/
17
-
18
17
class ValidateQuantity implements ArgumentInterface
19
18
{
19
+ /**
20
+ * @var Json
21
+ */
22
+ private Json $ serializer ;
23
+
20
24
/**
21
25
* @var ProductView
22
26
*/
23
- private $ productView ;
27
+ private ProductView $ productView ;
24
28
25
29
/**
30
+ * @param Json $serializer
26
31
* @param ProductView $productView
27
32
*/
28
- public function __construct (ProductView $ productView )
29
- {
33
+ public function __construct (
34
+ Json $ serializer ,
35
+ ProductView $ productView
36
+ ) {
37
+ $ this ->serializer = $ serializer ;
30
38
$ this ->productView = $ productView ;
31
39
}
32
40
33
- public function getQuantityValidators (): array
41
+ public function getQuantityValidators (): string
34
42
{
35
- return $ this ->productView ->getQuantityValidators ();
43
+ return $ this ->serializer ->serialize (
44
+ $ this ->productView ->getQuantityValidators ()
45
+ );
36
46
}
37
47
}
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ $viewModel = $block->getData('validateQuantityViewModel');
76
76
class="input-text qty<?php if (!$ _canChangeQty ) { echo ' qty-disabled ' ; } ?> "
77
77
type="number"
78
78
min="0"
79
- data-validate="<?= $ block ->escapeHtml ( json_encode ( $ viewModel ->getQuantityValidators () )) ?> "
79
+ data-validate="<?= $ block ->escapeHtmlAttr ( $ viewModel ->getQuantityValidators ()) ?> "
80
80
name="bundle_option_qty[<?= $ block ->escapeHtmlAttr ($ _option ->getId ()) ?> ]"
81
81
data-selector="bundle_option_qty[<?= $ block ->escapeHtmlAttr ($ _option ->getId ()) ?> ]"
82
82
value="<?= $ block ->escapeHtmlAttr ($ _defaultQty ) ?> "/>
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ $viewModel = $block->getData('validateQuantityViewModel');
62
62
class="input-text qty<?php if (!$ _canChangeQty ) { echo ' qty-disabled ' ; } ?> "
63
63
type="number"
64
64
min="0"
65
- data-validate="<?= $ block ->escapeHtml ( json_encode ( $ viewModel ->getQuantityValidators () )) ?> "
65
+ data-validate="<?= $ block ->escapeHtmlAttr ( $ viewModel ->getQuantityValidators ()) ?> "
66
66
name="bundle_option_qty[<?= $ block ->escapeHtmlAttr ($ _option ->getId ()) ?> ]"
67
67
data-selector="bundle_option_qty[<?= $ block ->escapeHtmlAttr ($ _option ->getId ()) ?> ]"
68
68
value="<?= $ block ->escapeHtmlAttr ($ _defaultQty ) ?> "/>
You can’t perform that action at this time.
0 commit comments