Skip to content

Commit 7fb1b3d

Browse files
author
Andrii Lugovyi
committed
Merge remote-tracking branch 'mainline/develop' into goinc-bugsfixing
2 parents 6d3a6a7 + ffa02d8 commit 7fb1b3d

File tree

425 files changed

+10749
-5243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

425 files changed

+10749
-5243
lines changed

app/code/Magento/Braintree/view/frontend/templates/creditcard/edit.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
/** @var $block \Magento\Braintree\Block\Creditcard\Management */
1010

1111
echo $block->getLayout()->getMessagesBlock()->getGroupedHtml();
12-
$defaultExpMonth = $block->getTodayMonth();
13-
$defaultExpYear = $block->getTodayYear();
12+
$defaultExpMonth = '';
13+
$defaultExpYear = '';
1414
$countrySpecificCardTypeConfig = $block->getCountrySpecificCardTypeConfig();
1515
$applicableCardTypeConfig = $block->getCcApplicableTypes();
1616
if ($block->isEditMode()) {
@@ -328,7 +328,7 @@ $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonE
328328
</label>
329329

330330
<div class="control">
331-
<?php echo $block->escapeHtml($block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default)); ?>
331+
<?php /* @noEscape */ echo $block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default); ?>
332332
</div>
333333
</div>
334334
</fieldset>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Bundle\Block\Adminhtml\Order\Create;
7+
8+
class Sidebar
9+
{
10+
/**
11+
* Get item qty
12+
*
13+
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
14+
* @param callable $proceed
15+
* @param \Magento\Framework\DataObject $item
16+
*
17+
* @return string
18+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
19+
*/
20+
public function aroundGetItemQty(
21+
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
22+
\Closure $proceed,
23+
\Magento\Framework\DataObject $item
24+
) {
25+
if ($item->getProduct()->getTypeId() == \Magento\Bundle\Model\Product\Type::TYPE_CODE) {
26+
return '';
27+
}
28+
return $proceed($item);
29+
}
30+
31+
/**
32+
* Check whether product configuration is required before adding to order
33+
*
34+
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
35+
* @param callable $proceed
36+
* @param string $productType
37+
*
38+
* @return bool
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
40+
*/
41+
public function aroundIsConfigurationRequired(
42+
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
43+
\Closure $proceed,
44+
$productType
45+
) {
46+
if ($productType == \Magento\Bundle\Model\Product\Type::TYPE_CODE) {
47+
return true;
48+
}
49+
return $proceed($productType);
50+
}
51+
}

app/code/Magento/Bundle/Model/Product/Price.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ public function getTotalBundleItemsPrice($product, $qty = null)
118118
{
119119
$price = 0.0;
120120
if ($product->hasCustomOptions()) {
121-
$customOption = $product->getCustomOption('bundle_selection_ids');
122-
if ($customOption) {
123-
$selectionIds = unserialize($customOption->getValue());
121+
$selectionIds = $this->getBundleSelectionIds($product);
122+
if ($selectionIds) {
124123
$selections = $product->getTypeInstance()->getSelectionsByIds($selectionIds, $product);
125124
$selections->addTierPriceData();
126125
$this->_eventManager->dispatch(
@@ -145,6 +144,24 @@ public function getTotalBundleItemsPrice($product, $qty = null)
145144
return $price;
146145
}
147146

147+
/**
148+
* Retrieve array of bundle selection IDs
149+
*
150+
* @param \Magento\Catalog\Model\Product $product
151+
* @return array
152+
*/
153+
protected function getBundleSelectionIds(\Magento\Catalog\Model\Product $product)
154+
{
155+
$customOption = $product->getCustomOption('bundle_selection_ids');
156+
if ($customOption) {
157+
$selectionIds = unserialize($customOption->getValue());
158+
if (!empty($selectionIds) && is_array($selectionIds)) {
159+
return $selectionIds;
160+
}
161+
}
162+
return [];
163+
}
164+
148165
/**
149166
* Get product final price
150167
*

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
*/
2020
class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
2121
{
22+
/**
23+
* Product type
24+
*/
25+
const TYPE_CODE = 'bundle';
26+
2227
/**
2328
* Product is composite
2429
*

app/code/Magento/Bundle/Test/Unit/Model/Product/PriceTest.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,121 @@ public function calculateSpecialPrice()
146146
[10, 100, 1, true, 10],
147147
];
148148
}
149+
150+
public function testGetTotalBundleItemsPriceWithNoCustomOptions()
151+
{
152+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
153+
->disableOriginalConstructor()
154+
->getMock();
155+
156+
$productMock->expects($this->once())
157+
->method('hasCustomOptions')
158+
->willReturn(false);
159+
160+
$this->assertEquals(0, $this->model->getTotalBundleItemsPrice($productMock));
161+
}
162+
163+
/**
164+
* @param string|null $value
165+
* @dataProvider dataProviderWithEmptyOptions
166+
*/
167+
public function testGetTotalBundleItemsPriceWithEmptyOptions($value)
168+
{
169+
$dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject')
170+
->setMethods(['getValue'])
171+
->disableOriginalConstructor()
172+
->getMock();
173+
174+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
175+
->disableOriginalConstructor()
176+
->getMock();
177+
178+
$productMock->expects($this->once())
179+
->method('hasCustomOptions')
180+
->willReturn(true);
181+
$productMock->expects($this->once())
182+
->method('getCustomOption')
183+
->with('bundle_selection_ids')
184+
->willReturn($dataObjectMock);
185+
186+
$dataObjectMock->expects($this->once())
187+
->method('getValue')
188+
->willReturn($value);
189+
190+
$this->assertEquals(0, $this->model->getTotalBundleItemsPrice($productMock));
191+
}
192+
193+
/**
194+
* @return array
195+
*/
196+
public function dataProviderWithEmptyOptions()
197+
{
198+
return [
199+
['a:0:{}'],
200+
[''],
201+
[null],
202+
];
203+
}
204+
205+
public function testGetTotalBundleItemsPriceWithNoItems()
206+
{
207+
$storeId = 1;
208+
209+
$dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject')
210+
->setMethods(['getValue'])
211+
->disableOriginalConstructor()
212+
->getMock();
213+
214+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
215+
->disableOriginalConstructor()
216+
->getMock();
217+
218+
$productTypeMock = $this->getMockBuilder('Magento\Bundle\Model\Product\Type')
219+
->disableOriginalConstructor()
220+
->getMock();
221+
222+
$selectionsMock = $this->getMockBuilder('Magento\Bundle\Model\ResourceModel\Selection\Collection')
223+
->disableOriginalConstructor()
224+
->getMock();
225+
226+
$productMock->expects($this->once())
227+
->method('hasCustomOptions')
228+
->willReturn(true);
229+
$productMock->expects($this->once())
230+
->method('getCustomOption')
231+
->with('bundle_selection_ids')
232+
->willReturn($dataObjectMock);
233+
$productMock->expects($this->once())
234+
->method('getTypeInstance')
235+
->willReturn($productTypeMock);
236+
$productMock->expects($this->once())
237+
->method('getStoreId')
238+
->willReturn($storeId);
239+
240+
$dataObjectMock->expects($this->once())
241+
->method('getValue')
242+
->willReturn('a:1:{i:0;s:1:"1";}');
243+
244+
$productTypeMock->expects($this->once())
245+
->method('getSelectionsByIds')
246+
->with([1], $productMock)
247+
->willReturn($selectionsMock);
248+
249+
$selectionsMock->expects($this->once())
250+
->method('addTierPriceData')
251+
->willReturnSelf();
252+
$selectionsMock->expects($this->once())
253+
->method('getItems')
254+
->willReturn([]);
255+
256+
$this->eventManagerMock->expects($this->once())
257+
->method('dispatch')
258+
->with(
259+
'prepare_catalog_product_collection_prices',
260+
['collection' => $selectionsMock, 'store_id' => $storeId]
261+
)
262+
->willReturnSelf();
263+
264+
$this->assertEquals(0, $this->model->getTotalBundleItemsPrice($productMock));
265+
}
149266
}

app/code/Magento/Bundle/etc/adminhtml/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
<type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper">
1010
<plugin name="Bundle" type="Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle" sortOrder="60" />
1111
</type>
12+
<type name="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar">
13+
<plugin name="Bundle" type="Magento\Bundle\Block\Adminhtml\Order\Create\Sidebar" sortOrder="200"/>
14+
</type>
1215
<type name="Magento\Catalog\Model\Product\CopyConstructor\Composite">
1316
<arguments>
1417
<argument name="constructors" xsi:type="array">

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ protected function _construct()
5454
$this->addButton(
5555
'save_in_new_set',
5656
[
57-
'label' => __('Save in New Product Template'),
57+
'label' => __('Save in New Attribute Set'),
5858
'class' => 'save',
59-
'onclick' => 'saveAttributeInNewSet(\'' . __('Enter Name for New Product Template') . '\')'
59+
'onclick' => 'saveAttributeInNewSet(\'' . __('Enter Name for New Attribute Set') . '\')'
6060
],
6161
100
6262
);

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function _prepareLayout()
129129
'label' => __('Delete'),
130130
'onclick' => 'deleteConfirm(\'' . $this->escapeJsQuote(
131131
__(
132-
'You are about to delete all products in this product template. '
132+
'You are about to delete all products in this attribute set. '
133133
. 'Are you sure you want to do that?'
134134
)
135135
) . '\', \'' . $this->getUrl(
@@ -187,7 +187,7 @@ public function getSetFormHtml()
187187
*/
188188
protected function _getHeader()
189189
{
190-
return __("Edit Product Template '%1'", $this->_getAttributeSet()->getAttributeSetName());
190+
return __("Edit Attribute Set '%1'", $this->_getAttributeSet()->getAttributeSetName());
191191
}
192192

193193
/**

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Main/Formset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function _prepareForm()
4343

4444
/** @var \Magento\Framework\Data\Form $form */
4545
$form = $this->_formFactory->create();
46-
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Product Template Name')]);
46+
$fieldset = $form->addFieldset('set_name', ['legend' => __('Edit Attribute Set Name')]);
4747
$fieldset->addField(
4848
'attribute_set_name',
4949
'text',

app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Set/Toolbar/Add.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected function _prepareLayout()
5757
*/
5858
protected function _getHeader()
5959
{
60-
return __('Add New Product Template');
60+
return __('Add New Attribute Set');
6161
}
6262

6363
/**

0 commit comments

Comments
 (0)