Skip to content

Commit 5965448

Browse files
author
Alexander Paliarush
committed
Merge remote-tracking branch 'origin/MAGETWO-53121-502-Bad-Gateway' into MAGETWO-53121-502-Bad-Gateway
2 parents b904a36 + cf3ed16 commit 5965448

File tree

6 files changed

+243
-15
lines changed

6 files changed

+243
-15
lines changed

app/code/Magento/Backup/Model/Fs/Collection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ protected function _generateRow($filename)
110110
$row[$key] = $value;
111111
}
112112
$row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
113-
$row['id'] = $row['time'] . '_' . $row['type'];
113+
if (isset($row['display_name']) && $row['display_name'] == '') {
114+
$row['display_name'] = 'WebSetupWizard';
115+
}
116+
$row['id'] = $row['time'] . '_' . $row['type'] . (isset($row['display_name']) ? $row['display_name'] : '');
114117
return $row;
115118
}
116119
}

app/code/Magento/Catalog/Helper/Product/ProductList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ProductList
1818
*/
1919
const XML_PATH_LIST_MODE = 'catalog/frontend/list_mode';
2020

21-
const VIEW_MODE_LIST = 'view';
21+
const VIEW_MODE_LIST = 'list';
2222
const VIEW_MODE_GRID = 'grid';
2323

2424
const DEFAULT_SORT_DIRECTION = 'asc';

app/code/Magento/Catalog/view/base/web/js/price-options.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ define([
7676
$(this.options.priceHolderSelector).trigger('updatePrice', changes);
7777
},
7878

79-
8079
/**
8180
* Helper to fix issue with option nodes:
8281
* - you can't place any html in option ->
@@ -174,7 +173,10 @@ define([
174173
break;
175174

176175
case 'radio':
177-
176+
if (element.is(':checked')) {
177+
changes[optionHash] = optionConfig[optionValue] && optionConfig[optionValue].prices || {};
178+
}
179+
break;
178180
case 'select-one':
179181
changes[optionHash] = optionConfig[optionValue] && optionConfig[optionValue].prices || {};
180182
break;

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
<script type="text/x-magento-init">
5454
{
5555
"#product_addtocart_form": {
56-
"catalogAddToCart": {}
56+
"catalogAddToCart": {
57+
"bindSubmit": false
58+
}
5759
}
5860
}
5961
</script>

app/code/Magento/CatalogUrlRewrite/Observer/ProductProcessUrlRewriteSavingObserver.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ public function execute(\Magento\Framework\Event\Observer $observer)
4646
/** @var \Magento\Catalog\Model\Product $product */
4747
$product = $observer->getEvent()->getProduct();
4848

49-
$isChangedWebsites = $product->getIsChangedWebsites();
50-
if ($product->dataHasChangedFor('url_key') || $product->getIsChangedCategories() || $isChangedWebsites
51-
|| $product->dataHasChangedFor('visibility')) {
52-
if ($isChangedWebsites) {
53-
$this->urlPersist->deleteByData([
54-
UrlRewrite::ENTITY_ID => $product->getId(),
55-
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
56-
]);
57-
}
58-
if (!in_array($product->getOrigData('visibility'), $product->getVisibleInSiteVisibilities())) {
49+
if ($product->dataHasChangedFor('url_key')
50+
|| $product->getIsChangedCategories()
51+
|| $product->getIsChangedWebsites()
52+
|| $product->dataHasChangedFor('visibility')
53+
) {
54+
$this->urlPersist->deleteByData([
55+
UrlRewrite::ENTITY_ID => $product->getId(),
56+
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
57+
UrlRewrite::REDIRECT_TYPE => 0,
58+
]);
59+
if ($product->isVisibleInSiteVisibility()) {
5960
$this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
6061
}
6162
}
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogUrlRewrite\Test\Unit\Observer;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
11+
use Magento\Store\Model\Store;
12+
use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
13+
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
14+
15+
/**
16+
* Class ProductProcessUrlRewriteSavingObserverTest
17+
*
18+
* @SuppressWarnings(PHPMD.TooManyFields)
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
*/
21+
class ProductProcessUrlRewriteSavingObserverTest extends \PHPUnit_Framework_TestCase
22+
{
23+
/**
24+
* @var \Magento\UrlRewrite\Model\UrlPersistInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $urlPersist;
27+
28+
/**
29+
* @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
protected $event;
32+
33+
/**
34+
* @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
protected $observer;
37+
38+
/**
39+
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
protected $product;
42+
43+
/**
44+
* @var \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
protected $productUrlRewriteGenerator;
47+
48+
/**
49+
* @var ObjectManager
50+
*/
51+
protected $objectManager;
52+
53+
/**
54+
* @var \Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver
55+
*/
56+
protected $model;
57+
58+
/**
59+
* Set up
60+
*/
61+
protected function setUp()
62+
{
63+
$this->urlPersist = $this->getMock(\Magento\UrlRewrite\Model\UrlPersistInterface::class, [], [], '', false);
64+
$this->product = $this->getMock(
65+
\Magento\Catalog\Model\Product::class,
66+
[
67+
'getId',
68+
'dataHasChangedFor',
69+
'isVisibleInSiteVisibility',
70+
'getIsChangedWebsites',
71+
'getIsChangedCategories'
72+
],
73+
[],
74+
'',
75+
false
76+
);
77+
$this->product->expects($this->any())->method('getId')->will($this->returnValue(3));
78+
$this->event = $this->getMock(\Magento\Framework\Event::class, ['getProduct'], [], '', false);
79+
$this->event->expects($this->any())->method('getProduct')->willReturn($this->product);
80+
$this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, ['getEvent'], [], '', false);
81+
$this->observer->expects($this->any())->method('getEvent')->willReturn($this->event);
82+
$this->productUrlRewriteGenerator = $this->getMock(
83+
\Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::class,
84+
['generate'],
85+
[],
86+
'',
87+
false
88+
);
89+
$this->productUrlRewriteGenerator->expects($this->any())
90+
->method('generate')
91+
->will($this->returnValue([3 => 'rewrite']));
92+
$this->objectManager = new ObjectManager($this);
93+
$this->model = $this->objectManager->getObject(
94+
\Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver::class,
95+
[
96+
'productUrlRewriteGenerator' => $this->productUrlRewriteGenerator,
97+
'urlPersist' => $this->urlPersist
98+
]
99+
);
100+
}
101+
102+
/**
103+
* Data provider
104+
*
105+
* @return array
106+
*/
107+
public function testUrlKeyDataProvider()
108+
{
109+
return [
110+
'url changed' => [
111+
'isChangedUrlKey' => true,
112+
'isChangedVisibility' => false,
113+
'isChangedWebsites' => false,
114+
'isChangedCategories' => false,
115+
'visibilityResult' => true,
116+
'expectedDeleteCount' => 1,
117+
'expectedReplaceCount' => 1
118+
],
119+
'no chnages' => [
120+
'isChangedUrlKey' => false,
121+
'isChangedVisibility' => false,
122+
'isChangedWebsites' => false,
123+
'isChangedCategories' => false,
124+
'visibilityResult' => true,
125+
'expectedDeleteCount' => 0,
126+
'expectedReplaceCount' => 0
127+
],
128+
'visibility changed' => [
129+
'isChangedUrlKey' => false,
130+
'isChangedVisibility' => true,
131+
'isChangedWebsites' => false,
132+
'isChangedCategories' => false,
133+
'visibilityResult' => true,
134+
'expectedDeleteCount' => 1,
135+
'expectedReplaceCount' => 1
136+
],
137+
'websites changed' => [
138+
'isChangedUrlKey' => false,
139+
'isChangedVisibility' => false,
140+
'isChangedWebsites' => true,
141+
'isChangedCategories' => false,
142+
'visibilityResult' => true,
143+
'expectedDeleteCount' => 1,
144+
'expectedReplaceCount' => 1
145+
],
146+
'categories changed' => [
147+
'isChangedUrlKey' => false,
148+
'isChangedVisibility' => false,
149+
'isChangedWebsites' => false,
150+
'isChangedCategories' => true,
151+
'visibilityResult' => true,
152+
'expectedDeleteCount' => 1,
153+
'expectedReplaceCount' => 1
154+
],
155+
'url changed invisible' => [
156+
'isChangedUrlKey' => true,
157+
'isChangedVisibility' => false,
158+
'isChangedWebsites' => false,
159+
'isChangedCategories' => false,
160+
'visibilityResult' => false,
161+
'expectedDeleteCount' => 1,
162+
'expectedReplaceCount' => 0
163+
],
164+
];
165+
}
166+
167+
/**
168+
* @param bool $isChangedUrlKey
169+
* @param bool $isChangedVisibility
170+
* @param bool $isChangedWebsites
171+
* @param bool $isChangedCategories
172+
* @param bool $visibilityResult
173+
* @param int $expectedDeleteCount
174+
* @param int $expectedReplaceCount
175+
*
176+
* @dataProvider testUrlKeyDataProvider
177+
*/
178+
public function testExecuteUrlKey(
179+
$isChangedUrlKey,
180+
$isChangedVisibility,
181+
$isChangedWebsites,
182+
$isChangedCategories,
183+
$visibilityResult,
184+
$expectedDeleteCount,
185+
$expectedReplaceCount
186+
) {
187+
$this->product->expects($this->any())
188+
->method('dataHasChangedFor')
189+
->will($this->returnValueMap(
190+
[
191+
['visibility', $isChangedVisibility],
192+
['url_key', $isChangedUrlKey]
193+
]
194+
));
195+
196+
$this->product->expects($this->any())
197+
->method('getIsChangedWebsites')
198+
->will($this->returnValue($isChangedWebsites));
199+
200+
$this->product->expects($this->any())
201+
->method('getIsChangedCategories')
202+
->will($this->returnValue($isChangedCategories));
203+
204+
$this->urlPersist->expects($this->exactly($expectedDeleteCount))->method('deleteByData')->with([
205+
UrlRewrite::ENTITY_ID => $this->product->getId(),
206+
UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
207+
UrlRewrite::REDIRECT_TYPE => 0,
208+
]);
209+
210+
$this->product->expects($this->any())
211+
->method('isVisibleInSiteVisibility')
212+
->will($this->returnValue($visibilityResult));
213+
214+
$this->urlPersist->expects($this->exactly($expectedReplaceCount))
215+
->method('replace')
216+
->with([3 => 'rewrite']);
217+
218+
$this->model->execute($this->observer);
219+
}
220+
}

0 commit comments

Comments
 (0)