Skip to content

Commit 2a3109a

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-MAGETWO-70163
2 parents 329c459 + 7978fcf commit 2a3109a

File tree

29 files changed

+971
-175
lines changed

29 files changed

+971
-175
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
687687
$options
688688
);
689689

690-
$optionsCollection->appendSelections($selections, false, $_appendAllSelections);
690+
$optionsCollection->appendSelections($selections, true, $_appendAllSelections);
691691

692692
$selections = $selections->getItems();
693693
} else {
@@ -704,7 +704,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
704704
->getOptionsIds($product);
705705
$selectionCollection = $product->getTypeInstance()
706706
->getSelectionsCollection($optionIds, $product);
707-
$options = $optionCollection->appendSelections($selectionCollection, false, $_appendAllSelections);
707+
$options = $optionCollection->appendSelections($selectionCollection, true, $_appendAllSelections);
708708

709709
$selections = $this->mergeSelectionsWithOptions($options, $selections);
710710
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ public function testPrepareForCartAdvancedWithoutOptions()
249249
->willReturn($productType);
250250
$optionCollection->expects($this->any())
251251
->method('appendSelections')
252+
->with($selectionCollection, true, true)
252253
->willReturn([$option]);
253254
$productType->expects($this->once())
254255
->method('setStoreFilter');
@@ -433,7 +434,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
433434
->method('getItemById')
434435
->willReturn($option);
435436
$optionCollection->expects($this->once())
436-
->method('appendSelections');
437+
->method('appendSelections')
438+
->with($selectionCollection, true, true);
437439
$productType->expects($this->once())
438440
->method('setStoreFilter');
439441
$buyRequest->expects($this->once())
@@ -668,7 +670,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
668670
->method('getItemById')
669671
->willReturn($option);
670672
$optionCollection->expects($this->once())
671-
->method('appendSelections');
673+
->method('appendSelections')
674+
->with($selectionCollection, true, true);
672675
$productType->expects($this->once())
673676
->method('setStoreFilter');
674677
$buyRequest->expects($this->once())
@@ -891,7 +894,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
891894
->method('getItemById')
892895
->willReturn($option);
893896
$optionCollection->expects($this->once())
894-
->method('appendSelections');
897+
->method('appendSelections')
898+
->with($selectionCollection, true, true);
895899
$productType->expects($this->once())
896900
->method('setStoreFilter');
897901
$buyRequest->expects($this->once())
@@ -1169,7 +1173,8 @@ function ($key) use ($optionCollection, $selectionCollection) {
11691173
}
11701174
);
11711175
$optionCollection->expects($this->once())
1172-
->method('appendSelections');
1176+
->method('appendSelections')
1177+
->with($selectionCollection, true, true);
11731178
$productType->expects($this->once())
11741179
->method('setStoreFilter');
11751180
$buyRequest->expects($this->once())

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Pricing\Price\AbstractPrice;
1717
use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
1818
use Magento\Framework\Pricing\PriceInfoInterface;
19+
use Magento\Customer\Model\Group\RetrieverInterface as CustomerGroupRetrieverInterface;
1920

2021
/**
2122
* @api
@@ -30,6 +31,7 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr
3031

3132
/**
3233
* @var Session
34+
* @deprecated
3335
*/
3436
protected $customerSession;
3537

@@ -57,30 +59,39 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr
5759
*/
5860
protected $groupManagement;
5961

62+
/**
63+
* @var CustomerGroupRetrieverInterface
64+
*/
65+
private $customerGroupRetriever;
66+
6067
/**
6168
* @param Product $saleableItem
6269
* @param float $quantity
6370
* @param CalculatorInterface $calculator
6471
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
6572
* @param Session $customerSession
6673
* @param GroupManagementInterface $groupManagement
74+
* @param CustomerGroupRetrieverInterface|null $customerGroupRetriever
6775
*/
6876
public function __construct(
6977
Product $saleableItem,
7078
$quantity,
7179
CalculatorInterface $calculator,
7280
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
7381
Session $customerSession,
74-
GroupManagementInterface $groupManagement
82+
GroupManagementInterface $groupManagement,
83+
CustomerGroupRetrieverInterface $customerGroupRetriever = null
7584
) {
7685
$quantity = $quantity ?: 1;
7786
parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
7887
$this->customerSession = $customerSession;
7988
$this->groupManagement = $groupManagement;
89+
$this->customerGroupRetriever = $customerGroupRetriever
90+
?? \Magento\Framework\App\ObjectManager::getInstance()->get(CustomerGroupRetrieverInterface::class);
8091
if ($saleableItem->hasCustomerGroupId()) {
8192
$this->customerGroup = (int) $saleableItem->getCustomerGroupId();
8293
} else {
83-
$this->customerGroup = (int) $this->customerSession->getCustomerGroupId();
94+
$this->customerGroup = (int) $this->customerGroupRetriever->getCustomerGroupId();
8495
}
8596
}
8697

app/code/Magento/Catalog/Test/Unit/Pricing/Price/TierPriceTest.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,52 @@ class TierPriceTest extends \PHPUnit\Framework\TestCase
2525
*
2626
* @var int
2727
*/
28-
protected $customerGroup = Group::NOT_LOGGED_IN_ID;
28+
private $customerGroup = Group::NOT_LOGGED_IN_ID;
2929

3030
/**
3131
* @var \PHPUnit_Framework_MockObject_MockObject
3232
*/
33-
protected $priceInfo;
33+
private $priceInfo;
3434

3535
/**
3636
* @var \PHPUnit_Framework_MockObject_MockObject
3737
*/
38-
protected $product;
38+
private $product;
3939

4040
/**
4141
* @var float
4242
*/
43-
protected $quantity = 3.;
43+
private $quantity = 3.;
4444

4545
/**
4646
* @var \PHPUnit_Framework_MockObject_MockObject
4747
*/
48-
protected $calculator;
48+
private $calculator;
4949

5050
/**
5151
* @var \PHPUnit_Framework_MockObject_MockObject
5252
*/
53-
protected $session;
53+
private $session;
5454

5555
/**
5656
* @var TierPrice
5757
*/
58-
protected $model;
58+
private $model;
5959

6060
/**
6161
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
6262
*/
63-
protected $priceCurrencyMock;
63+
private $priceCurrencyMock;
6464

6565
/**
6666
* @var \PHPUnit_Framework_MockObject_MockObject
6767
*/
68-
protected $groupManagement;
68+
private $groupManagement;
69+
70+
/**
71+
* @var \Magento\Customer\Model\Group\RetrieverInterface|\PHPUnit_Framework_MockObject_MockObject
72+
*/
73+
private $customerGroupRetriever;
6974

7075
/**
7176
* Initialize base dependencies
@@ -76,11 +81,12 @@ protected function setUp()
7681

7782
$this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getPriceInfo', 'hasCustomerGroupId', 'getCustomerGroupId', 'getResource', '__wakeup']);
7883
$this->product->expects($this->any())->method('getPriceInfo')->will($this->returnValue($this->priceInfo));
79-
84+
$this->customerGroupRetriever = $this->getMockBuilder(\Magento\Customer\Model\Group\RetrieverInterface::class)
85+
->disableOriginalConstructor()->getMock();
8086
$this->session = $this->createMock(\Magento\Customer\Model\Session::class);
8187
$this->session->expects($this->any())->method('getCustomerGroupId')
8288
->will($this->returnValue($this->customerGroup));
83-
89+
$this->customerGroupRetriever = $this->createMock(\Magento\Customer\Model\Group\RetrieverInterface::class);
8490
$this->calculator = $this->createMock(\Magento\Framework\Pricing\Adjustment\Calculator::class);
8591
$this->groupManagement = $this->createMock(\Magento\Customer\Api\GroupManagementInterface::class);
8692

@@ -92,7 +98,8 @@ protected function setUp()
9298
$this->calculator,
9399
$this->priceCurrencyMock,
94100
$this->session,
95-
$this->groupManagement
101+
$this->groupManagement,
102+
$this->customerGroupRetriever
96103
);
97104
}
98105

@@ -218,7 +225,8 @@ public function testGetterStoredTierPrices()
218225
$this->calculator,
219226
$this->priceCurrencyMock,
220227
$this->session,
221-
$this->groupManagement
228+
$this->groupManagement,
229+
$this->customerGroupRetriever
222230
);
223231
$group = $this->createMock(\Magento\Customer\Model\Data\Group::class);
224232
$group->expects($this->once())->method('getId')->willReturn(GroupManagement::CUST_GROUP_ALL);

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ protected function getConditions()
259259
$conditions = $this->conditionsHelper->decode($conditions);
260260
}
261261

262+
foreach ($conditions as $key => $condition) {
263+
if (!empty($condition['attribute'])
264+
&& in_array($condition['attribute'], ['special_from_date', 'special_to_date'])
265+
) {
266+
$conditions[$key]['value'] = date('Y-m-d H:i:s', strtotime($condition['value']));
267+
}
268+
}
269+
262270
$this->rule->loadPost(['conditions' => $conditions]);
263271
return $this->rule->getConditions();
264272
}

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,11 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
288288
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
289289
$this->productsList->setData('conditions_encoded', 'some_serialized_conditions');
290290

291+
$this->widgetConditionsHelper->expects($this->once())
292+
->method('decode')
293+
->with('some_serialized_conditions')
294+
->willReturn([]);
295+
291296
$this->builder->expects($this->once())->method('attachConditionToCollection')
292297
->with($collection, $this->getConditionsForCollection($collection))
293298
->willReturnSelf();

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\ConfigurableProduct\Model\ConfigurableAttributeData;
1111
use Magento\Customer\Helper\Session\CurrentCustomer;
12+
use Magento\Customer\Model\Session;
1213
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\Locale\Format;
1415
use Magento\Framework\Pricing\PriceCurrencyInterface;
@@ -31,6 +32,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
3132
/**
3233
* Current customer
3334
*
35+
* @deprecated, as unused property
3436
* @var CurrentCustomer
3537
*/
3638
protected $currentCustomer;
@@ -67,6 +69,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
6769
*/
6870
private $localeFormat;
6971

72+
/**
73+
* @var Session
74+
*/
75+
private $customerSession;
76+
7077
/**
7178
* @param \Magento\Catalog\Block\Product\Context $context
7279
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -78,6 +85,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
7885
* @param ConfigurableAttributeData $configurableAttributeData
7986
* @param array $data
8087
* @param Format|null $localeFormat
88+
* @param Session|null $customerSession
8189
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8290
*/
8391
public function __construct(
@@ -90,7 +98,8 @@ public function __construct(
9098
PriceCurrencyInterface $priceCurrency,
9199
ConfigurableAttributeData $configurableAttributeData,
92100
array $data = [],
93-
Format $localeFormat = null
101+
Format $localeFormat = null,
102+
Session $customerSession = null
94103
) {
95104
$this->priceCurrency = $priceCurrency;
96105
$this->helper = $helper;
@@ -99,6 +108,7 @@ public function __construct(
99108
$this->currentCustomer = $currentCustomer;
100109
$this->configurableAttributeData = $configurableAttributeData;
101110
$this->localeFormat = $localeFormat ?: ObjectManager::getInstance()->get(Format::class);
111+
$this->customerSession = $customerSession ?: ObjectManager::getInstance()->get(Session::class);
102112

103113
parent::__construct(
104114
$context,
@@ -117,6 +127,7 @@ public function getCacheKeyInfo()
117127
{
118128
$parentData = parent::getCacheKeyInfo();
119129
$parentData[] = $this->priceCurrency->getCurrencySymbol();
130+
$parentData[] = $this->customerSession->getCustomerGroupId();
120131
return $parentData;
121132
}
122133

0 commit comments

Comments
 (0)