Skip to content

Commit

Permalink
Merge pull request #304 from magento-dragons/DRAGONS-PR-12
Browse files Browse the repository at this point in the history
[Dragons] Bug Fixing
Fixes:
- Image does not save when edited via right-click and "Insert/Edit Image"
- Scope selector on product page does not display all related websites for restricted user
- Prices of related products on PDP changes according to product custom options
- Swatches not displayed when using search
- Reordered items count is not getting updated at mini cart
  • Loading branch information
Alexander Akimov authored Sep 1, 2016
2 parents d323ecb + 6fae14c commit 7f4417e
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 12 deletions.
8 changes: 1 addition & 7 deletions app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

/**
* Store switcher block
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Switcher extends \Magento\Backend\Block\Template
{
Expand Down Expand Up @@ -152,11 +150,7 @@ public function getWebsites()
{
$websites = $this->_storeManager->getWebsites();
if ($websiteIds = $this->getWebsiteIds()) {
foreach (array_keys($websites) as $websiteId) {
if (!in_array($websiteId, $websiteIds)) {
unset($websites[$websiteId]);
}
}
$websites = array_intersect_key($websites, array_flip($websiteIds));
}
return $websites;
}
Expand Down
53 changes: 53 additions & 0 deletions app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Test\Unit\Block\Store;

class SwitcherTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Backend\Block\Store\Switcher
*/
private $switcherBlock;

private $storeManagerMock;

protected function setUp()
{
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$context = $objectHelper->getObject(
\Magento\Backend\Block\Template\Context::class,
[
'storeManager' => $this->storeManagerMock,
]
);

$this->switcherBlock = $objectHelper->getObject(
\Magento\Backend\Block\Store\Switcher::class,
['context' => $context]
);
}

public function testGetWebsites()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
$this->assertEquals($websites, $this->switcherBlock->getWebsites());
}

public function testGetWebsitesIfSetWebsiteIds()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));

$this->switcherBlock->setWebsiteIds([1]);
$expected = [1 => $websiteMock];
$this->assertEquals($expected, $this->switcherBlock->getWebsites());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
'jquery',
'priceBox'
], function($){
var priceBoxes = $('[data-role=priceBox]');
var dataPriceBoxSelector = '[data-role=priceBox]',
dataProductIdSelector = '[data-product-id=<?php echo $block->escapeHtml($_product->getId())?>]',
priceBoxes = $(dataPriceBoxSelector + dataProductIdSelector);

priceBoxes = priceBoxes.filter(function(index, elem){
return !$(elem).find('.price-from').length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
?>

<?php $_options = $block->decorateArray($block->getOptions()) ?>
<?php $_productId = $block->getProduct()->getId() ?>
<?php if (count($_options)):?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"priceOptions": {
"optionConfig": <?php /* @escapeNotVerified */ echo $block->getJsonConfig()?>,
"controlContainer": ".field",
"priceHolderSelector": "[data-role=priceBox]"
"priceHolderSelector": "[data-product-id='<?php echo $block->escapeHtml($_productId)?>'][data-role=priceBox]"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
</a>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<div class="actions">
<?php $_order = $block->getOrder() ?>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a class="action reorder" href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
</a>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_Swatches::css/swatches.css"/>
</head>
<body>
<referenceBlock name="category.product.type.details.renderers">
<block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />
</referenceBlock>
</body>
</page>
1 change: 1 addition & 0 deletions lib/web/tiny_mce/plugins/advimage/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ var ImageDialog = {
tinyMCEPopup.editor.execCommand('mceRepaint');
tinyMCEPopup.editor.focus();
tinyMCEPopup.close();
ed.onChange.dispatch(ed);
},

getAttrib : function(e, at) {
Expand Down

0 comments on commit 7f4417e

Please sign in to comment.