Skip to content

Commit a48c797

Browse files
MAGETWO-86331: Issues #10559 - Extend swatch using mixins (M2.1) #12928
- Merge Pull Request #12928 from srenon/magento2:patch-7 - Merged commits: 1. 155f91c
2 parents 46dce62 + 155f91c commit a48c797

File tree

1 file changed

+16
-16
lines changed
  • app/code/Magento/Swatches/view/frontend/templates/product/listing

1 file changed

+16
-16
lines changed

app/code/Magento/Swatches/view/frontend/templates/product/listing/renderer.phtml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
* See COPYING.txt for license details.
55
*/
66
?>
7-
<?php /** @var $block \Magento\Swatches\Block\Product\Renderer\Listing\Configurable */ ?>
8-
<div class="swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>"></div>
9-
<script>
10-
require(
11-
["jquery", "jquery/ui", "Magento_Swatches/js/swatch-renderer", "Magento_Swatches/js/catalog-add-to-cart"],
12-
function ($) {
13-
$('.swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>').SwatchRenderer({
14-
selectorProduct: '.product-item-details',
15-
onlySwatches: true,
16-
enableControlLabel: false,
17-
numberToShow: <?php /* @escapeNotVerified */ echo $block->getNumberSwatchesPerProduct(); ?>,
18-
jsonConfig: <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>,
19-
jsonSwatchConfig: <?php /* @escapeNotVerified */ echo $block->getJsonSwatchConfig(); ?>,
20-
mediaCallback: '<?php /* @escapeNotVerified */ echo $block->getMediaCallback() ?>'
21-
});
22-
});
7+
<div class="swatch-opt-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>" data-role="swatch-option-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>"></div>
8+
9+
<script type="text/x-magento-init">
10+
{
11+
"[data-role=swatch-option-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>]": {
12+
"Magento_Swatches/js/swatch-renderer": {
13+
"selectorProduct": ".product-item-details",
14+
"onlySwatches": true,
15+
"enableControlLabel": false,
16+
"numberToShow": <?php /* @escapeNotVerified */ echo $block->getNumberSwatchesPerProduct(); ?>,
17+
"jsonConfig": <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>,
18+
"jsonSwatchConfig": <?php /* @escapeNotVerified */ echo $block->getJsonSwatchConfig(); ?>,
19+
"mediaCallback": "<?php /* @escapeNotVerified */ echo $block->getMediaCallback() ?>"
20+
}
21+
}
22+
}
2323
</script>

0 commit comments

Comments
 (0)