Skip to content

Commit 494a30a

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into MAGETWO-44464
2 parents fb67016 + 1f0b802 commit 494a30a

File tree

207 files changed

+1439
-655
lines changed

Some content is hidden

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

207 files changed

+1439
-655
lines changed

app/code/Magento/Backend/Block/Widget/Button/Item.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace Magento\Backend\Block\Widget\Button;
88

99
/**
10-
* @method string getButtonKey
11-
* @method string getRegion
12-
* @method string getName
13-
* @method int getLevel
14-
* @method int getSortOrder
15-
* @method string getTitle
10+
* @method string getButtonKey()
11+
* @method string getRegion()
12+
* @method string getName()
13+
* @method int getLevel()
14+
* @method int getSortOrder()
15+
* @method string getTitle()
1616
*/
1717
class Item extends \Magento\Framework\DataObject
1818
{

app/code/Magento/Backend/Block/Widget/Button/Toolbar/Container.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Magento\Backend\Block\Widget\Button\ContextInterface;
1010

1111
/**
12-
* @method \Magento\Backend\Block\Widget\Button\Item getButtonItem
13-
* @method ContextInterface getContext
12+
* @method \Magento\Backend\Block\Widget\Button\Item getButtonItem()
13+
* @method ContextInterface getContext()
1414
* @method ContextInterface setContext(ContextInterface $context)
1515
*/
1616
class Container extends \Magento\Framework\View\Element\AbstractBlock

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/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/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/Edit/Tab/Advanced.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ class Advanced extends Generic
3131
*/
3232
protected $_yesNo;
3333

34+
/**
35+
* @var array
36+
*/
37+
protected $disableScopeChangeList;
38+
3439
/**
3540
* @param \Magento\Backend\Block\Template\Context $context
3641
* @param \Magento\Framework\Registry $registry
3742
* @param \Magento\Framework\Data\FormFactory $formFactory
3843
* @param Yesno $yesNo
3944
* @param Data $eavData
45+
* @param array $disableScopeChangeList
4046
* @param array $data
4147
*/
4248
public function __construct(
@@ -45,10 +51,12 @@ public function __construct(
4551
\Magento\Framework\Data\FormFactory $formFactory,
4652
Yesno $yesNo,
4753
Data $eavData,
54+
array $disableScopeChangeList = ['sku'],
4855
array $data = []
4956
) {
5057
$this->_yesNo = $yesNo;
5158
$this->_eavData = $eavData;
59+
$this->disableScopeChangeList = $disableScopeChangeList;
5260
parent::__construct($context, $registry, $formFactory, $data);
5361
}
5462

@@ -229,7 +237,7 @@ protected function _prepareForm()
229237
);
230238

231239
$this->_eventManager->dispatch('product_attribute_form_build', ['form' => $form]);
232-
if ($attributeObject->getId() && !$attributeObject->getIsUserDefined()) {
240+
if (in_array($attributeObject->getAttributeCode(), $this->disableScopeChangeList)) {
233241
$form->getElement('is_global')->setDisabled(1);
234242
}
235243
$this->setForm($form);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Product attribute add/edit form options tab
99
*
1010
* @method \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Options setReadOnly(bool $value)
11-
* @method null|bool getReadOnly
11+
* @method null|bool getReadOnly()
1212
*
1313
* @author Magento Core Team <core@magentocommerce.com>
1414
*/

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)