Skip to content

Commit 00d657a

Browse files
🔃 [EngCom] Public Pull Requests - 2.1-develop
Accepted Public Pull Requests: - #12928: Issues #10559 - Extend swatch using mixins (M2.1) (by @srenon) - #14151: [Backport 2.1] 8373: Fix CURL Json POST (by @simpleadm) Fixed GitHub Issues: - #10559: Extending swatch functionality using javascript mixins does not work in Safari and MS Edge (reported by @srenon) has been fixed in #12928 by @srenon in 2.1-develop branch Related commits: 1. 155f91c - #3489: CURL Json POST (reported by @Grohotun) has been fixed in #14151 by @simpleadm in 2.1-develop branch Related commits: 1. a676af8
2 parents 08648cb + e9fb542 commit 00d657a

File tree

2 files changed

+29
-19
lines changed
  • app/code/Magento/Swatches/view/frontend/templates/product/listing
  • lib/internal/Magento/Framework/HTTP/Client

2 files changed

+29
-19
lines changed

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
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() ?>"
8+
data-role="swatch-option-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>"
9+
></div>
10+
11+
<script type="text/x-magento-init">
12+
{
13+
"[data-role=swatch-option-<?php /* @escapeNotVerified */ echo $block->getProduct()->getId() ?>]": {
14+
"Magento_Swatches/js/swatch-renderer": {
15+
"selectorProduct": ".product-item-details",
16+
"onlySwatches": true,
17+
"enableControlLabel": false,
18+
"numberToShow": <?php /* @escapeNotVerified */ echo $block->getNumberSwatchesPerProduct(); ?>,
19+
"jsonConfig": <?php /* @escapeNotVerified */ echo $block->getJsonConfig(); ?>,
20+
"jsonSwatchConfig": <?php /* @escapeNotVerified */ echo $block->getJsonSwatchConfig(); ?>,
21+
"mediaCallback": "<?php /* @escapeNotVerified */ echo $block->getMediaCallback() ?>"
22+
},
23+
"Magento_Swatches/js/catalog-add-to-cart": {}
24+
}
25+
}
2326
</script>

lib/internal/Magento/Framework/HTTP/Client/Curl.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,11 @@ public function get($uri)
222222
/**
223223
* Make POST request
224224
*
225+
* String type was added to parameter $param in order to support sending JSON or XML requests.
226+
* This feature was added base on Community Pull Request https://github.com/magento/magento2/pull/8373
227+
*
225228
* @param string $uri
226-
* @param array $params
229+
* @param array|string $params
227230
* @return void
228231
*
229232
* @see \Magento\Framework\HTTP\Client#post($uri, $params)
@@ -327,9 +330,13 @@ public function getStatus()
327330

328331
/**
329332
* Make request
333+
*
334+
* String type was added to parameter $param in order to support sending JSON or XML requests.
335+
* This feature was added base on Community Pull Request https://github.com/magento/magento2/pull/8373
336+
*
330337
* @param string $method
331338
* @param string $uri
332-
* @param array $params
339+
* @param array|string $params - use $params as a string in case of JSON or XML POST request.
333340
* @return void
334341
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
335342
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -340,7 +347,7 @@ protected function makeRequest($method, $uri, $params = [])
340347
$this->curlOption(CURLOPT_URL, $uri);
341348
if ($method == 'POST') {
342349
$this->curlOption(CURLOPT_POST, 1);
343-
$this->curlOption(CURLOPT_POSTFIELDS, http_build_query($params));
350+
$this->curlOption(CURLOPT_POSTFIELDS, is_array($params) ? http_build_query($params) : $params);
344351
} elseif ($method == "GET") {
345352
$this->curlOption(CURLOPT_HTTPGET, 1);
346353
} else {

0 commit comments

Comments
 (0)