Skip to content

Commit 05e71fb

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into develop
2 parents 139f567 + f2a66a4 commit 05e71fb

File tree

73 files changed

+1575
-158
lines changed

Some content is hidden

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

73 files changed

+1575
-158
lines changed

app/code/Magento/Backend/view/adminhtml/templates/page/js/calendar.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ require([
5050
showTime: false,
5151
showHour: false,
5252
showMinute: false,
53+
serverTimezoneSeconds: <?php echo (int) $block->getStoreTimestamp(); ?>,
5354
yearRange: '<?php /* @escapeNotVerified */ echo $block->getYearRange() ?>'
5455
}
5556
});

app/code/Magento/Backend/view/adminhtml/ui_component/design_config_form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
</field>
7575
<field name="theme">
7676
<argument name="data" xsi:type="array">
77-
<item name="options" xsi:type="object">Magento\Framework\View\Design\Theme\Label</item>
77+
<item name="options" xsi:type="object">Magento\Theme\Model\Design\Theme\Label</item>
7878
<item name="config" xsi:type="array">
7979
<item name="formElement" xsi:type="string">select</item>
8080
<item name="dataType" xsi:type="string">text</item>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ public function getFinalPrice($qty, $product)
183183
$finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
184184
$finalPrice += $this->getTotalBundleItemsPrice($product, $qty);
185185

186+
$finalPrice = max(0, $finalPrice);
186187
$product->setFinalPrice($finalPrice);
187-
return max(0, $product->getData('final_price'));
188+
return $finalPrice;
188189
}
189190

190191
/**
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
namespace Magento\Catalog\Api;
8+
9+
interface AttributeSetFinderInterface
10+
{
11+
/**
12+
* Get attribute set ids by product ids
13+
*
14+
* @param array $productIds
15+
* @return array
16+
*/
17+
public function findAttributeSetIdsByProductIds(array $productIds);
18+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ protected function _prepareForm()
7070
}
7171
$this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields);
7272

73-
$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
74-
7573
$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
7674
$frontendInputElm->setValues($frontendInputValues);
7775

76+
$this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
77+
7878
return $this;
7979
}
8080

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function createActionPage($title = null)
8888
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
8989
$resultPage = $this->resultPageFactory->create();
9090
if ($this->getRequest()->getParam('popup')) {
91-
if ($this->getRequest()->getParam('product_tab') == 'variations') {
91+
if ($this->getRequest()->getParam('product_tab') === 'variations') {
9292
$resultPage->addHandle(['popup', 'catalog_product_attribute_edit_product_tab_variations_popup']);
9393
} else {
9494
$resultPage->addHandle(['popup', 'catalog_product_attribute_edit_popup']);

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StockDataFilter
1616
/**
1717
* The greatest value which could be stored in CatalogInventory Qty field
1818
*/
19-
const MAX_QTY_VALUE = 99999999.9999;
19+
const MAX_QTY_VALUE = 99999999;
2020

2121
/**
2222
* @var ScopeConfigInterface

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
142142
*/
143143
protected $optionInstance;
144144

145-
/**
146-
* @var bool
147-
*/
148-
protected $optionsInitialized = false;
149-
150145
/**
151146
* @var array
152147
*/
@@ -1901,6 +1896,7 @@ public function addOption(Product\Option $option)
19011896
{
19021897
$options = (array)$this->getData('options');
19031898
$options[] = $option;
1899+
$option->setProduct($this);
19041900
$this->setData('options', $options);
19051901
return $this;
19061902
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Product\Attribute;
7+
8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
10+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11+
use Magento\Catalog\Api\AttributeSetFinderInterface;
12+
use Magento\Framework\DB\Select;
13+
14+
class AttributeSetFinder implements AttributeSetFinderInterface
15+
{
16+
/**
17+
* @var CollectionFactory
18+
*/
19+
private $productCollectionFactory;
20+
21+
/**
22+
* @param CollectionFactory $productCollectionFactory
23+
*/
24+
public function __construct(CollectionFactory $productCollectionFactory)
25+
{
26+
$this->productCollectionFactory = $productCollectionFactory;
27+
}
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public function findAttributeSetIdsByProductIds(array $productIds)
33+
{
34+
/** @var $collection Collection */
35+
$collection = $this->productCollectionFactory->create();
36+
$select = $collection
37+
->getSelect()
38+
->reset(Select::COLUMNS)
39+
->columns(ProductInterface::ATTRIBUTE_SET_ID)
40+
->where('entity_id IN (?)', $productIds)
41+
->group(ProductInterface::ATTRIBUTE_SET_ID);
42+
$result = $collection->getConnection()->fetchCol($select);
43+
return $result;
44+
}
45+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
*
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
namespace Magento\Catalog\Test\Unit\Model\Product\Attribute;
8+
9+
use Magento\Catalog\Api\Data\ProductInterface;
10+
use Magento\Catalog\Model\Product\Attribute\AttributeSetFinder;
11+
use Magento\Catalog\Model\ResourceModel\Product\Collection;
12+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
14+
use Magento\Framework\DB\Select;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
17+
class AttributeSetFinderTest extends \PHPUnit_Framework_TestCase
18+
{
19+
/**
20+
* @var Collection|\PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
protected $productCollection;
23+
24+
/**
25+
* @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
26+
*/
27+
protected $productCollectionFactory;
28+
29+
/**
30+
* @var AttributeSetFinder
31+
*/
32+
protected $attributeSetFinder;
33+
34+
protected function setUp()
35+
{
36+
$this->productCollection = $this->getMockBuilder(Collection::class)
37+
->disableOriginalConstructor()
38+
->getMock();
39+
$this->productCollectionFactory = $this->getMockBuilder(CollectionFactory::class)
40+
->setMethods(['create'])
41+
->disableOriginalConstructor()
42+
->getMock();
43+
$this->productCollectionFactory->expects($this->once())->method('create')->willReturn($this->productCollection);
44+
45+
$this->attributeSetFinder = (new ObjectManager($this))->getObject(
46+
AttributeSetFinder::class,
47+
[
48+
'productCollectionFactory' => $this->productCollectionFactory,
49+
]
50+
);
51+
}
52+
53+
public function testFindAttributeIdsByProductIds()
54+
{
55+
$productIds = [1, 2, 3];
56+
$attributeSetIds = [3, 4, 6];
57+
58+
$select = $this->getMockBuilder(Select::class)
59+
->disableOriginalConstructor()
60+
->getMock();
61+
$select->expects($this->once())->method('reset')->with(Select::COLUMNS)->willReturnSelf();
62+
$select->expects($this->once())->method('columns')->with(ProductInterface::ATTRIBUTE_SET_ID)->willReturnSelf();
63+
$select->expects($this->once())->method('where')->with('entity_id IN (?)', $productIds)->willReturnSelf();
64+
$select->expects($this->once())->method('group')->with(ProductInterface::ATTRIBUTE_SET_ID)->willReturnSelf();
65+
66+
$connection = $this->getMock(AdapterInterface::class);
67+
$connection->expects($this->once())->method('fetchCol')->with($select)->willReturn($attributeSetIds);
68+
69+
$this->productCollection->expects($this->once())->method('getSelect')->willReturn($select);
70+
$this->productCollection->expects($this->once())->method('getConnection')->willReturn($connection);
71+
72+
$this->assertEquals($attributeSetIds, $this->attributeSetFinder->findAttributeSetIdsByProductIds($productIds));
73+
}
74+
}

0 commit comments

Comments
 (0)