Skip to content

Commit c42d2cf

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #45 from magento-folks/bugs
[Folks] Bugfix
2 parents be268e8 + 0c3afac commit c42d2cf

File tree

35 files changed

+351
-112
lines changed

35 files changed

+351
-112
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ protected function initializeProductData(array $productData, $createNew)
286286
if ($createNew) {
287287
$product = $this->productFactory->create();
288288
if ($this->storeManager->hasSingleStore()) {
289-
$product->setWebsiteIds([$this->storeManager->getStore(true)->getWebsite()->getId()]);
289+
$product->setWebsiteIds([$this->storeManager->getStore(true)->getWebsiteId()]);
290+
} elseif (isset($productData['store_id'])
291+
&& !empty($productData['store_id'])
292+
&& $this->storeManager->getStore($productData['store_id'])
293+
) {
294+
$product->setWebsiteIds([$this->storeManager->getStore($productData['store_id'])->getWebsiteId()]);
290295
}
291296
} else {
292297
unset($this->instances[$productData['sku']]);

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,38 @@ class Product extends AbstractPlugin
1111
/**
1212
* Reindex on product save
1313
*
14-
* @param \Magento\Catalog\Model\Product $product
15-
* @return \Magento\Catalog\Model\Product
14+
* @param \Magento\Catalog\Model\ResourceModel\Product $productResource
15+
* @param \Closure $proceed
16+
* @param \Magento\Framework\Model\AbstractModel $product
17+
* @return \Magento\Catalog\Model\ResourceModel\Product
18+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1619
*/
17-
public function afterSave(\Magento\Catalog\Model\Product $product)
18-
{
20+
public function aroundSave(
21+
\Magento\Catalog\Model\ResourceModel\Product $productResource,
22+
\Closure $proceed,
23+
\Magento\Framework\Model\AbstractModel $product
24+
) {
25+
$result = $proceed($product);
1926
$this->reindexRow($product->getId());
20-
return $product;
27+
return $result;
2128
}
2229

2330
/**
2431
* Reindex on product delete
2532
*
26-
* @param \Magento\Catalog\Model\Product $product
27-
* @return \Magento\Catalog\Model\Product
33+
* @param \Magento\Catalog\Model\ResourceModel\Product $productResource
34+
* @param \Closure $proceed
35+
* @param \Magento\Framework\Model\AbstractModel $product
36+
* @return \Magento\Catalog\Model\ResourceModel\Product
37+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2838
*/
29-
public function afterDelete(\Magento\Catalog\Model\Product $product)
30-
{
39+
public function aroundDelete(
40+
\Magento\Catalog\Model\ResourceModel\Product $productResource,
41+
\Closure $proceed,
42+
\Magento\Framework\Model\AbstractModel $product
43+
) {
44+
$result = $proceed($product);
3145
$this->reindexRow($product->getId());
32-
return $product;
46+
return $result;
3347
}
3448
}

app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Fulltext/Plugin/ProductTest.php

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ class ProductTest extends \PHPUnit_Framework_TestCase
1616
protected $indexerMock;
1717

1818
/**
19-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
19+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Product
2020
*/
2121
protected $subjectMock;
2222

23+
/**
24+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product
25+
*/
26+
protected $productMock;
27+
28+
/**
29+
* @var \Closure
30+
*/
31+
protected $proceed;
32+
2333
/**
2434
* @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject
2535
*/
@@ -32,8 +42,8 @@ class ProductTest extends \PHPUnit_Framework_TestCase
3242

3343
protected function setUp()
3444
{
35-
$this->subjectMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false);
36-
45+
$this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false);
46+
$this->subjectMock = $this->getMock('Magento\Catalog\Model\ResourceModel\Product', [], [], '', false);
3747
$this->indexerMock = $this->getMockForAbstractClass(
3848
'Magento\Framework\Indexer\IndexerInterface',
3949
[],
@@ -43,7 +53,6 @@ protected function setUp()
4353
true,
4454
['getId', 'getState', '__wakeup']
4555
);
46-
4756
$this->indexerRegistryMock = $this->getMock(
4857
'Magento\Framework\Indexer\IndexerRegistry',
4958
['get'],
@@ -52,6 +61,10 @@ protected function setUp()
5261
false
5362
);
5463

64+
$this->proceed = function () {
65+
return $this->subjectMock;
66+
};
67+
5568
$this->model = new Product($this->indexerRegistryMock);
5669
}
5770

@@ -61,9 +74,12 @@ public function testAfterSaveNonScheduled()
6174
$this->indexerMock->expects($this->once())->method('reindexRow')->with(1);
6275
$this->prepareIndexer();
6376

64-
$this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1));
77+
$this->productMock->expects($this->once())->method('getId')->will($this->returnValue(1));
6578

66-
$this->assertEquals($this->subjectMock, $this->model->afterSave($this->subjectMock));
79+
$this->assertEquals(
80+
$this->subjectMock,
81+
$this->model->aroundSave($this->subjectMock, $this->proceed, $this->productMock)
82+
);
6783
}
6884

6985
public function testAfterSaveScheduled()
@@ -72,9 +88,12 @@ public function testAfterSaveScheduled()
7288
$this->indexerMock->expects($this->never())->method('reindexRow');
7389
$this->prepareIndexer();
7490

75-
$this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1));
91+
$this->productMock->expects($this->once())->method('getId')->will($this->returnValue(1));
7692

77-
$this->assertEquals($this->subjectMock, $this->model->afterSave($this->subjectMock));
93+
$this->assertEquals(
94+
$this->subjectMock,
95+
$this->model->aroundSave($this->subjectMock, $this->proceed, $this->productMock)
96+
);
7897
}
7998

8099
public function testAfterDeleteNonScheduled()
@@ -83,9 +102,12 @@ public function testAfterDeleteNonScheduled()
83102
$this->indexerMock->expects($this->once())->method('reindexRow')->with(1);
84103
$this->prepareIndexer();
85104

86-
$this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1));
105+
$this->productMock->expects($this->once())->method('getId')->will($this->returnValue(1));
87106

88-
$this->assertEquals($this->subjectMock, $this->model->afterDelete($this->subjectMock));
107+
$this->assertEquals(
108+
$this->subjectMock,
109+
$this->model->aroundDelete($this->subjectMock, $this->proceed, $this->productMock)
110+
);
89111
}
90112

91113
public function testAfterDeleteScheduled()
@@ -94,9 +116,12 @@ public function testAfterDeleteScheduled()
94116
$this->indexerMock->expects($this->never())->method('reindexRow');
95117
$this->prepareIndexer();
96118

97-
$this->subjectMock->expects($this->once())->method('getId')->will($this->returnValue(1));
119+
$this->productMock->expects($this->once())->method('getId')->will($this->returnValue(1));
98120

99-
$this->assertEquals($this->subjectMock, $this->model->afterDelete($this->subjectMock));
121+
$this->assertEquals(
122+
$this->subjectMock,
123+
$this->model->aroundDelete($this->subjectMock, $this->proceed, $this->productMock)
124+
);
100125
}
101126

102127
protected function prepareIndexer()

app/code/Magento/CatalogSearch/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</argument>
3434
</arguments>
3535
</type>
36-
<type name="Magento\Catalog\Model\Product">
36+
<type name="Magento\Catalog\Model\ResourceModel\Product">
3737
<plugin name="catalogsearchFulltextProduct" type="Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product"/>
3838
</type>
3939
<type name="Magento\Catalog\Model\Product\Action">

app/code/Magento/Checkout/Model/Cart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ protected function _getProductRequest($requestInfo)
324324
if (!$request->hasQty()) {
325325
$request->setQty(1);
326326
}
327+
!$request->hasFormKey() ?: $request->unsFormKey();
327328

328329
return $request;
329330
}

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
6262
*/
6363
private $httpContext;
6464

65-
/**
66-
* @var CurrencyManager
67-
*/
68-
private $currencyManager;
69-
7065
/**
7166
* @var QuoteRepository
7267
*/
@@ -174,7 +169,6 @@ class DefaultConfigProvider implements ConfigProviderInterface
174169
* @param CustomerSession $customerSession
175170
* @param CustomerUrlManager $customerUrlManager
176171
* @param HttpContext $httpContext
177-
* @param CurrencyManager $currencyManager
178172
* @param QuoteRepository $quoteRepository
179173
* @param QuoteItemRepository $quoteItemRepository
180174
* @param ShippingMethodManager $shippingMethodManager
@@ -205,7 +199,6 @@ public function __construct(
205199
CustomerSession $customerSession,
206200
CustomerUrlManager $customerUrlManager,
207201
HttpContext $httpContext,
208-
CurrencyManager $currencyManager,
209202
QuoteRepository $quoteRepository,
210203
QuoteItemRepository $quoteItemRepository,
211204
ShippingMethodManager $shippingMethodManager,
@@ -233,7 +226,6 @@ public function __construct(
233226
$this->customerSession = $customerSession;
234227
$this->customerUrlManager = $customerUrlManager;
235228
$this->httpContext = $httpContext;
236-
$this->currencyManager = $currencyManager;
237229
$this->quoteRepository = $quoteRepository;
238230
$this->quoteItemRepository = $quoteItemRepository;
239231
$this->shippingMethodManager = $shippingMethodManager;
@@ -282,7 +274,7 @@ public function getConfig()
282274
);
283275
$output['basePriceFormat'] = $this->localeFormat->getPriceFormat(
284276
null,
285-
$this->currencyManager->getDefaultCurrency()
277+
$this->checkoutSession->getQuote()->getBaseCurrencyCode()
286278
);
287279
$output['postCodes'] = $this->postCodesConfig->getPostCodes();
288280
$output['imageData'] = $this->imageProvider->getImages($quoteId);

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ define([
1010
'Magento_Customer/js/customer-data',
1111
'Magento_Ui/js/modal/alert',
1212
'Magento_Ui/js/modal/confirm',
13+
'Magento_Customer/js/customer-data',
1314
"jquery/ui",
1415
"mage/decorate"
15-
], function($, authenticationPopup, customerData, alert, confirm){
16+
], function($, authenticationPopup, customerData, alert, confirm, customerData){
1617

1718
$.widget('mage.sidebar', {
1819
options: {
@@ -21,8 +22,19 @@ define([
2122
},
2223
scrollHeight: 0,
2324

24-
_create: function() {
25+
/**
26+
* Create sidebar.
27+
* @private
28+
*/
29+
_create: function () {
30+
var self = this;
31+
2532
this._initContent();
33+
customerData.get('cart').subscribe(function () {
34+
$(self.options.targetElement).trigger('contentUpdated');
35+
self._calcHeight();
36+
self._isOverflowed();
37+
});
2638
},
2739

2840
_initContent: function() {
@@ -67,6 +79,9 @@ define([
6779
event.stopPropagation();
6880
self._updateItemQty($(event.currentTarget));
6981
};
82+
events['focusout ' + this.options.item.qty] = function(event) {
83+
self._validateQty($(event.currentTarget));
84+
};
7085

7186
this._on(this.element, events);
7287
this._calcHeight();
@@ -95,7 +110,6 @@ define([
95110
if (this._isValidQty(itemQty, elem.val())) {
96111
$('#update-cart-item-' + itemId).show('fade', 300);
97112
} else if (elem.val() == 0) {
98-
elem.val(itemQty);
99113
this._hideItemButton(elem);
100114
} else {
101115
this._hideItemButton(elem);
@@ -115,6 +129,18 @@ define([
115129
&& (changed - 0 > 0);
116130
},
117131

132+
/**
133+
* @param {Object} elem
134+
* @private
135+
*/
136+
_validateQty: function(elem) {
137+
var itemQty = elem.data('item-qty');
138+
139+
if (!this._isValidQty(itemQty, elem.val())) {
140+
elem.val(itemQty);
141+
}
142+
},
143+
118144
_hideItemButton: function(elem) {
119145
var itemId = elem.data('cart-item');
120146
$('#update-cart-item-' + itemId).hide('fade', 300);

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ define(
145145
} else {
146146
this.source.set('params.invalid', false);
147147
this.source.trigger(this.dataScopePrefix + '.data.validate');
148+
if (this.source.get(this.dataScopePrefix + '.custom_attributes')) {
149+
this.source.trigger(this.dataScopePrefix + '.custom_attributes.data.validate');
150+
};
148151

149152
if (!this.source.get('params.invalid')) {
150153
var addressData = this.source.get(this.dataScopePrefix),

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ define([
7272
this.isLoading(addToCartCalls > 0);
7373
sidebarInitialized = false;
7474
initSidebar();
75-
76-
/**TODO: Extra options support. Should be refactored after MAGETWO-43159. */
77-
setInterval(function(){
78-
minicart.trigger('contentUpdated');
79-
}, 500);
80-
8175
}, this);
8276
$('[data-block="minicart"]').on('contentLoading', function(event) {
8377
addToCartCalls++;

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ define(
201201
}
202202
},
203203

204-
validateShippingInformation: function() {
204+
validateShippingInformation: function () {
205205
var shippingAddress,
206206
addressData,
207207
loginFormSelector = 'form[data-role=email-with-possible-login]',
@@ -224,6 +224,9 @@ define(
224224
if (this.isFormInline) {
225225
this.source.set('params.invalid', false);
226226
this.source.trigger('shippingAddress.data.validate');
227+
if (this.source.get('shippingAddress.custom_attributes')) {
228+
this.source.trigger('shippingAddress.custom_attributes.data.validate');
229+
};
227230
if (this.source.get('params.invalid')
228231
|| !quote.shippingMethod().method_code
229232
|| !quote.shippingMethod().carrier_code

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ protected function _saveAttribute($object, $attribute, $value)
15131513
'value' => $this->_prepareValueForSave($value, $attribute),
15141514
];
15151515

1516-
if (!$this->getEntityTable()) {
1516+
if (!$this->getEntityTable() || $this->getEntityTable() == \Magento\Eav\Model\Entity::DEFAULT_ENTITY_TABLE) {
15171517
$data['entity_type_id'] = $object->getEntityTypeId();
15181518
}
15191519

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public function beforeSave()
242242
)
243243
) {
244244
throw new LocalizedException(
245-
__('An attribute code must be fewer than %1 characters.', self::ATTRIBUTE_CODE_MAX_LENGTH)
245+
__('An attribute code must not be more than %1 characters.', self::ATTRIBUTE_CODE_MAX_LENGTH)
246246
);
247247
}
248248

app/code/Magento/Eav/Setup/EavSetup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ private function _validateAttributeData($data)
728728
)
729729
) {
730730
throw new LocalizedException(
731-
__('An attribute code must be fewer than %1 characters.', $attributeCodeMaxLength)
731+
__('An attribute code must not be more than %1 characters.', $attributeCodeMaxLength)
732732
);
733733
}
734734

app/code/Magento/Payment/view/frontend/web/transparent.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ define([
4646
.off('click')
4747
.on('click', $.proxy(this._placeOrderHandler, this));
4848
}
49+
50+
this.element.validation();
51+
$('[data-container="' + this.options.gateway + '-cc-number"]').on('focusout', function () {
52+
$(this).valid();
53+
});
4954
},
5055

5156
/**

0 commit comments

Comments
 (0)