|
5 | 5 | */ |
6 | 6 | ?> |
7 | 7 | <?php /** @var $block \Magento\Swatches\Block\Product\Renderer\Listing\Configurable */ ?> |
8 | | -<div class="swatch-opt-<?= /* @escapeNotVerified */ $block->getProduct()->getId() ?>"></div> |
9 | | -<script> |
10 | | - require([ |
11 | | - 'jquery', |
12 | | - 'jquery/ui', |
13 | | - 'Magento_Swatches/js/swatch-renderer', |
14 | | - 'Magento_Swatches/js/catalog-add-to-cart', |
15 | | - 'priceBox' |
16 | | - ], function ($) { |
17 | | - var jsonConfig = <?= /* @escapeNotVerified */ $block->getJsonConfig() ?>; |
| 8 | +<div class="swatch-opt-<?= /* @escapeNotVerified */ $block->getProduct()->getId() ?>" data-role="swatch-option-<?= /* @escapeNotVerified */ $block->getProduct()->getId() ?>"></div> |
18 | 9 |
|
19 | | - $('.swatch-opt-<?= /* @escapeNotVerified */ $block->getProduct()->getId() ?>').SwatchRenderer({ |
20 | | - selectorProduct: '.product-item-details', |
21 | | - onlySwatches: true, |
22 | | - enableControlLabel: false, |
23 | | - numberToShow: <?= /* @escapeNotVerified */ $block->getNumberSwatchesPerProduct() ?>, |
24 | | - jsonConfig: jsonConfig, |
25 | | - jsonSwatchConfig: <?= /* @escapeNotVerified */ $block->getJsonSwatchConfig() ?>, |
26 | | - mediaCallback: '<?= /* @escapeNotVerified */ $block->getMediaCallback() ?>' |
27 | | - }); |
28 | | - |
29 | | - var dataPriceBoxSelector = '[data-role=priceBox]', |
30 | | - dataProductIdSelector = '[data-product-id=<?= $block->escapeHtml($block->getProduct()->getId()) ?>]', |
31 | | - priceBoxes = $(dataPriceBoxSelector + dataProductIdSelector); |
| 10 | +<script type="text/x-magento-init"> |
| 11 | + { |
| 12 | + "[data-role=swatch-option-<?= /* @escapeNotVerified */ $block->getProduct()->getId() ?>]": { |
| 13 | + "Magento_Swatches/js/swatch-renderer": { |
| 14 | + "selectorProduct": ".product-item-details", |
| 15 | + "onlySwatches": true, |
| 16 | + "enableControlLabel": false, |
| 17 | + "numberToShow": <?= /* @escapeNotVerified */ $block->getNumberSwatchesPerProduct(); ?>, |
| 18 | + "jsonConfig": <?= /* @escapeNotVerified */ $block->getJsonConfig(); ?>, |
| 19 | + "jsonSwatchConfig": <?= /* @escapeNotVerified */ $block->getJsonSwatchConfig(); ?>, |
| 20 | + "mediaCallback": "<?= /* @escapeNotVerified */ $block->getMediaCallback() ?>" |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | +</script> |
32 | 25 |
|
33 | | - priceBoxes.priceBox({ |
34 | | - 'priceConfig': { |
35 | | - priceFormat: jsonConfig.priceFormat, |
36 | | - prices: jsonConfig.prices |
| 26 | +<script type="text/x-magento-init"> |
| 27 | + { |
| 28 | + "[data-role=priceBox][data-price-box=product-id-<?= $block->escapeHtml($block->getProduct()->getId()) ?>]": { |
| 29 | + "priceBox": { |
| 30 | + "priceConfig": { |
| 31 | + "priceFormat": <?= $block->getPriceFormatJson(); ?>, |
| 32 | + "prices": <?= $block->getPricesJson(); ?> |
| 33 | + } |
37 | 34 | } |
38 | | - }); |
39 | | - }); |
| 35 | + } |
| 36 | + } |
40 | 37 | </script> |
0 commit comments