Skip to content

Commit e604d5e

Browse files
author
Anna Bukatar
committed
MDVA-140: Product images not switching when clicking on swatch
1 parent 108f839 commit e604d5e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/code/Magento/Swatches/Block/Product/Renderer/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,6 @@ protected function getHtmlOutput()
390390
*/
391391
public function getMediaCallback()
392392
{
393-
return $this->getBaseUrl() . self::MEDIA_CALLBACK_ACTION;
393+
return $this->getUrl(self::MEDIA_CALLBACK_ACTION, ['_secure' => $this->getRequest()->isSecure()]);
394394
}
395395
}

app/code/Magento/Swatches/Test/Unit/Block/Product/Renderer/ConfigurableTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,13 @@ public function testGetJsonSwatchConfigWithoutVisualImageType()
311311

312312
public function testGetMediaCallback()
313313
{
314-
$this->urlBuilder->expects($this->once())->method('getBaseUrl')->willReturn('http://magento.com/');
315-
$this->assertContains(Configurable::MEDIA_CALLBACK_ACTION, $this->configurable->getMediaCallback());
314+
$url = 'http://localhost/' . Configurable::MEDIA_CALLBACK_ACTION;
315+
316+
$this->urlBuilder->expects($this->once())
317+
->method('getUrl')
318+
->with(Configurable::MEDIA_CALLBACK_ACTION)
319+
->willReturn($url);
320+
321+
$this->assertEquals($url, $this->configurable->getMediaCallback());
316322
}
317323
}

0 commit comments

Comments
 (0)