<?php
/**
 * @category Mageants SimpleConfigurable
 * @package Mageants_SimpleConfigurable
 * @copyright Copyright (c) 2017 Mageants
 * @author Mageants Team <info@mageants.com>
 */
?>
<?php
    /** @var $block \Magento\Swatches\Block\Product\Renderer\Listing\Configurable */
    $productId = $block->getProduct()->getId();
?>
<div class="swatch-opt-<?= /* @noEscape */ $productId ?>"
     data-role="swatch-option-<?= /* @noEscape */ $productId ?>"></div>
<?php $isEnable = $block->isEnable(); ?>
<?php if ($isEnable && $block->getPreselectOptionId()) {  ?>
                <script type="text/x-magento-init">
                    {
                        "[data-role=swatch-option-<?= /* @noEscape */ $productId ?>]": {
                            "Magento_Swatches/js/swatch-renderer": {
                                "selectorProduct": ".product-item-details",
                                "onlySwatches": true,
                                "enableControlLabel": false,
                                "numberToShow": <?= /* @noEscape */ $block->getNumberSwatchesPerProduct(); ?>,
                                "jsonConfig": <?= /* @noEscape */ $block->getJsonConfig(); ?>,
                                "jsonSwatchConfig": <?= /* @noEscape */ $block->getJsonSwatchConfig(); ?>,
                                "mediaCallback": "<?= /* @noEscape */ $block->getMediaCallback() ?>",
                                "preSelectedOption": <?= /* @noEscape */ __($block->getPreselectOptionId()) ?>,
                                "customAttributes": "",
                                "productUrls": "",
                                "replaceUrl" : ""
                            }
                        }
                    }
                </script>

                <script type="text/x-magento-init">
                    {
                        "[data-role=priceBox][data-price-box=product-id-<?= /* @noEscape */ $productId ?>]": {
                            "priceBox": {
                                "priceConfig": {
                                    "priceFormat": <?= /* @noEscape */ $block->getPriceFormatJson(); ?>,
                                    "prices": <?= /* @noEscape */ $block->getPricesJson(); ?>
                                }
                            }
                        }
                    }
                </script>
<?php } else {  ?>
                <script type="text/x-magento-init">
                    {
                        "[data-role=swatch-option-<?= /* @noEscape */ $productId ?>]": {
                            "Magento_Swatches/js/swatch-renderer": {
                                "selectorProduct": ".product-item-details",
                                "onlySwatches": true,
                                "enableControlLabel": false,
                                "numberToShow": <?= /* @noEscape */ $block->getNumberSwatchesPerProduct(); ?>,
                                "jsonConfig": <?= /* @noEscape */ $block->getJsonConfig(); ?>,
                                "jsonSwatchConfig": <?= /* @noEscape */ $block->getJsonSwatchConfig(); ?>,
                                "mediaCallback": "<?= /* @noEscape */ $block->getMediaCallback() ?>"
                            }
                        }
                    }
                </script>

                <script type="text/x-magento-init">
                    {
                        "[data-role=priceBox][data-price-box=product-id-<?= /* @noEscape */ $productId ?>]": {
                            "priceBox": {
                                "priceConfig": {
                                    "priceFormat": <?= /* @noEscape */ $block->getPriceFormatJson(); ?>,
                                    "prices": <?= /* @noEscape */ $block->getPricesJson(); ?>
                                }
                            }
                        }
                    }
                </script>
<?php } ?>
