Skip to content

Commit 0b10f87

Browse files
author
Michael Logvin
committed
Merge remote-tracking branch 'magento-goinc/MAGETWO-35379' into last_bugs
2 parents dddabda + 567082b commit 0b10f87

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,9 @@ public function getJsonConfig()
187187
'amount' => $this->_registerJsPrice($this->_convertPrice($regularPrice->getAmount()->getValue())),
188188
],
189189
'basePrice' => [
190-
'amount' =>
191-
$this->_registerJsPrice($this->_convertPrice($finalPrice->getAmount()->getBaseAmount())),
190+
'amount' => $this->_registerJsPrice(
191+
$this->_convertPrice($finalPrice->getAmount()->getBaseAmount())
192+
),
192193
],
193194
'finalPrice' => [
194195
'amount' => $this->_registerJsPrice($this->_convertPrice($finalPrice->getAmount()->getValue())),
@@ -197,7 +198,6 @@ public function getJsonConfig()
197198
'productId' => $currentProduct->getId(),
198199
'chooseText' => __('Choose an Option...'),
199200
'images' => isset($options['images']) ? $options['images'] : [],
200-
'baseImage' => $options['baseImage'],
201201
];
202202

203203
if ($currentProduct->hasPreconfiguredValues() && !empty($attributesData['defaultValues'])) {

app/code/Magento/ConfigurableProduct/Helper/Data.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function getOptions($currentProduct, $allowedProducts)
5858
$options['images'][$productAttributeId][$attributeValue][$productId] = $imageUrl;
5959
}
6060
}
61-
$options['baseImage'] = $baseImageUrl;
6261

6362
return $options;
6463
}

app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ public function getOptionsDataProvider()
8282
);
8383
$provider = [];
8484
$provider[] = [
85-
['baseImage' => 'http://example.com/base_img_url'],
85+
[],
8686
[
8787
'allowed_products' => [],
8888
'current_product_mock' => $currentProductMock,
89-
'baseImage' => 'http://example.com/base_img_url'
9089
],
9190
];
9291

@@ -163,12 +162,10 @@ public function getOptionsDataProvider()
163162
'attribute_id_2' => [
164163
'attribute_code_value_2' => ['product_id_1', 'product_id_2'],
165164
],
166-
'baseImage' => 'http://example.com/base_img_url',
167165
],
168166
[
169167
'allowed_products' => $allowedProducts,
170168
'current_product_mock' => $currentProductMock,
171-
'baseImage' => 'http://example.com/base_img_url'
172169
],
173170
];
174171
return $provider;

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ define([
1010
"priceUtils",
1111
"priceBox",
1212
"jquery/ui",
13-
"jquery/jquery.parsequery"
13+
"jquery/jquery.parsequery",
14+
"mage/gallery"
1415
], function($, _, mageTemplate, utils){
1516

1617
$.widget('mage.configurable', {
@@ -69,6 +70,10 @@ define([
6970

7071
this.options.values = this.options.spConfig.defaultValues || {};
7172
this.options.parentImage = $('[data-role=base-image-container] img').attr('src');
73+
74+
this.initialGalleryImages = $(this.options.mediaGallerySelector).data('mageGallery')
75+
? $(this.options.mediaGallerySelector).gallery('option', 'images')
76+
: [];
7277
this.inputSimpleProduct = this.element.find(this.options.selectSimpleProduct);
7378
},
7479

@@ -226,12 +231,7 @@ define([
226231
_changeProductImage: function () {
227232
var images = this.options.spConfig.images,
228233
imagesArray = null,
229-
galleryElement = $(this.options.mediaGallerySelector),
230-
baseImage = {
231-
small: this.options.spConfig.baseImage,
232-
medium: this.options.spConfig.baseImage,
233-
large: this.options.spConfig.baseImage
234-
};
234+
galleryElement = $(this.options.mediaGallerySelector);
235235
$.each(this.options.settings, function (k, v) {
236236
var selectValue = parseInt(v.value, 10),
237237
attributeId = v.id.replace(/[a-z]*/, '');
@@ -251,18 +251,16 @@ define([
251251
});
252252

253253
var result = [];
254-
$.each(imagesArray || baseImage, function (k, v) {
254+
$.each(imagesArray || {}, function (k, v) {
255255
result.push({
256256
small: v,
257257
medium: v,
258258
large: v
259259
});
260260
});
261-
if (result.length !== 1) {
262-
result = [baseImage];
263-
}
261+
264262
if (galleryElement.length && galleryElement.data('mageGallery')) {
265-
galleryElement.gallery('option', 'images', result);
263+
galleryElement.gallery('option', 'images', result.length > 0 ? result : this.initialGalleryImages);
266264
}
267265
},
268266

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testGetAllowProducts()
6969
$this->assertInstanceOf('Magento\Catalog\Model\Product', $product);
7070
}
7171
}
72-
72+
7373
/**
7474
* @magentoAppIsolation enabled
7575
*/
@@ -79,7 +79,6 @@ public function testGetJsonConfig()
7979
$this->assertNotEmpty($config);
8080
$this->assertArrayHasKey('productId', $config);
8181
$this->assertEquals(1, $config['productId']);
82-
$this->assertArrayHasKey('baseImage', $config);
8382
$this->assertArrayHasKey('attributes', $config);
8483
$this->assertArrayHasKey('template', $config);
8584
$this->assertArrayHasKey('prices', $config);

0 commit comments

Comments
 (0)