Skip to content

Commit 66cf5b7

Browse files
author
Igor Miniailo
committed
Merge branch 'develop' into product-video-PR4
2 parents 20a2d90 + 681bc1b commit 66cf5b7

File tree

133 files changed

+2472
-1188
lines changed

Some content is hidden

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

133 files changed

+2472
-1188
lines changed

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ protected function populateAuthorizeRequest(InfoInterface $payment, $token)
409409
if ($token) {
410410
$transactionParams['paymentMethodToken'] = $token;
411411
$transactionParams['customerId'] = $customerId;
412+
$transactionParams['billing'] = $this->toBraintreeAddress($billing);
413+
$transactionParams['shipping'] = $this->toBraintreeAddress($shipping);
412414
} elseif ($this->getInfoInstance()->getAdditionalInformation('payment_method_nonce')) {
413415
$transactionParams['paymentMethodNonce'] =
414416
$this->getInfoInstance()->getAdditionalInformation('payment_method_nonce');

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethodTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,6 @@ public function authorizeDataProvider()
13611361
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
13621362
'paymentMethodToken' => self::CC_TOKEN,
13631363
'customerId' => self::CUSTOMER_ID,
1364-
'billing' => null,
1365-
'shipping' => null,
13661364
'deviceData' => 'fraud_detection_data',
13671365
],
13681366
'braintree_response' => [
@@ -1429,8 +1427,6 @@ public function authorizeDataProvider()
14291427
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
14301428
'paymentMethodNonce' => self::PAYMENT_METHOD_NONCE,
14311429
'customerId' => self::CUSTOMER_ID,
1432-
'billing' => null,
1433-
'shipping' => null,
14341430
'deviceData' => 'fraud_detection_data',
14351431
'options' => [
14361432
'three_d_secure' => [
@@ -1502,8 +1498,6 @@ public function authorizeDataProvider()
15021498
'merchantAccountId' => self::MERCHANT_ACCOUNT_ID,
15031499
'paymentMethodToken' => self::CC_TOKEN,
15041500
'customerId' => self::CUSTOMER_ID,
1505-
'billing' => null,
1506-
'shipping' => null,
15071501
'deviceData' => 'fraud_detection_data',
15081502
],
15091503
'braintree_response' => [

app/code/Magento/Bundle/Pricing/Adjustment/BundleCalculatorInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ interface BundleCalculatorInterface extends CalculatorInterface
1717
/**
1818
* @param float|string $amount
1919
* @param Product $saleableItem
20-
* @param null|bool $exclude
20+
* @param null|bool|string|array $exclude
2121
* @return \Magento\Framework\Pricing\Amount\AmountInterface
2222
*/
2323
public function getMaxAmount($amount, Product $saleableItem, $exclude = null);
2424

2525
/**
2626
* @param float|string $amount
2727
* @param Product $saleableItem
28-
* @param null|bool $exclude
28+
* @param null|bool|string|array $exclude
2929
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3030
*/
3131
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null);
3232

3333
/**
3434
* @param float|string $amount
3535
* @param Product $saleableItem
36-
* @param null|bool $exclude
36+
* @param null|bool|string|array $exclude
3737
* @return \Magento\Framework\Pricing\Amount\AmountInterface
3838
*/
3939
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null);
@@ -42,7 +42,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
4242
* Option amount calculation for saleable item
4343
*
4444
* @param Product $saleableItem
45-
* @param null|string $exclude
45+
* @param null|bool|string|array $exclude
4646
* @param bool $searchMin
4747
* @param \Magento\Framework\Pricing\Amount\AmountInterface|null $bundleProductAmount
4848
* @return \Magento\Framework\Pricing\Amount\AmountInterface
@@ -60,7 +60,7 @@ public function getOptionsAmount(
6060
* @param float $basePriceValue
6161
* @param Product $bundleProduct
6262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
63-
* @param null|string $exclude code of adjustment that has to be excluded
63+
* @param null|bool|string|array $exclude code of adjustment that has to be excluded
6464
* @return \Magento\Framework\Pricing\Amount\AmountInterface
6565
*/
6666
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null);

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function __construct(
7777
*
7878
* @param float|string $amount
7979
* @param SaleableInterface $saleableItem
80-
* @param null|string $exclude
80+
* @param null|bool|string|array $exclude
8181
* @param null|array $context
8282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
8383
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -92,7 +92,7 @@ public function getAmount($amount, SaleableInterface $saleableItem, $exclude = n
9292
*
9393
* @param float $amount
9494
* @param Product $saleableItem
95-
* @param null|string $exclude
95+
* @param null|bool|string|array $exclude
9696
* @return \Magento\Framework\Pricing\Amount\AmountInterface
9797
*/
9898
public function getMinRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -105,7 +105,7 @@ public function getMinRegularAmount($amount, Product $saleableItem, $exclude = n
105105
*
106106
* @param float $amount
107107
* @param Product $saleableItem
108-
* @param null|string $exclude
108+
* @param null|bool|string|array $exclude
109109
* @return \Magento\Framework\Pricing\Amount\AmountInterface
110110
*/
111111
public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
@@ -118,7 +118,7 @@ public function getMaxAmount($amount, Product $saleableItem, $exclude = null)
118118
*
119119
* @param float $amount
120120
* @param Product $saleableItem
121-
* @param null|string $exclude
121+
* @param null|bool|string|array $exclude
122122
* @return \Magento\Framework\Pricing\Amount\AmountInterface
123123
*/
124124
public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = null)
@@ -130,7 +130,7 @@ public function getMaxRegularAmount($amount, Product $saleableItem, $exclude = n
130130
* Option amount calculation for bundle product
131131
*
132132
* @param Product $saleableItem
133-
* @param null|string $exclude
133+
* @param null|bool|string|array $exclude
134134
* @param bool $searchMin
135135
* @param float $baseAmount
136136
* @param bool $useRegularPrice
@@ -260,7 +260,7 @@ protected function getBundleOptions(Product $saleableItem)
260260
* @param float $basePriceValue
261261
* @param Product $bundleProduct
262262
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
263-
* @param null|string $exclude
263+
* @param null|bool|string|array $exclude
264264
* @return \Magento\Framework\Pricing\Amount\AmountInterface
265265
*/
266266
public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null)
@@ -278,7 +278,7 @@ public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectio
278278
* @param float $basePriceValue
279279
* @param Product $bundleProduct
280280
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
281-
* @param null|string $exclude
281+
* @param null|bool|string|arrayy $exclude
282282
* @return \Magento\Framework\Pricing\Amount\AmountInterface
283283
*/
284284
protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude)
@@ -297,7 +297,7 @@ protected function calculateFixedBundleAmount($basePriceValue, $bundleProduct, $
297297
* @param float $basePriceValue
298298
* @param Product $bundleProduct
299299
* @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
300-
* @param null|string $exclude
300+
* @param null|bool|string|array $exclude
301301
* @return \Magento\Framework\Pricing\Amount\AmountInterface
302302
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
303303
*/
@@ -340,9 +340,18 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct,
340340
}
341341
}
342342
}
343-
if ($exclude && isset($adjustments[$exclude])) {
344-
$fullAmount -= $adjustments[$exclude];
345-
unset($adjustments[$exclude]);
343+
if (is_array($exclude) == false) {
344+
if ($exclude && isset($adjustments[$exclude])) {
345+
$fullAmount -= $adjustments[$exclude];
346+
unset($adjustments[$exclude]);
347+
}
348+
} else {
349+
foreach ($exclude as $oneExclusion) {
350+
if ($oneExclusion && isset($adjustments[$oneExclusion])) {
351+
$fullAmount -= $adjustments[$oneExclusion];
352+
unset($adjustments[$oneExclusion]);
353+
}
354+
}
346355
}
347356
return $this->amountFactory->create($fullAmount, $adjustments);
348357
}

app/code/Magento/Bundle/Pricing/Price/BundleSelectionPrice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class BundleSelectionPrice extends AbstractPrice
6868
* @param ManagerInterface $eventManager
6969
* @param DiscountCalculator $discountCalculator
7070
* @param bool $useRegularPrice
71-
* @param string $excludeAdjustment
71+
* @param array $excludeAdjustment
7272
*/
7373
public function __construct(
7474
Product $saleableItem,

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,21 @@ protected function addFilterGroupToCollection(
684684
Collection $collection
685685
) {
686686
$fields = [];
687+
$categoryFilter = [];
687688
foreach ($filterGroup->getFilters() as $filter) {
688-
$condition = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
689-
$fields[] = ['attribute' => $filter->getField(), $condition => $filter->getValue()];
689+
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
690+
691+
if ($filter->getField() == 'category_id') {
692+
$categoryFilter[$conditionType][] = $filter->getValue();
693+
continue;
694+
}
695+
$fields[] = ['attribute' => $filter->getField(), $conditionType => $filter->getValue()];
690696
}
697+
698+
if ($categoryFilter) {
699+
$collection->addCategoriesFilter($categoryFilter);
700+
}
701+
691702
if ($fields) {
692703
$collection->addFieldToFilter($fields);
693704
}

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,40 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
840840
return $this;
841841
}
842842

843+
/**
844+
* Filter Product by Categories
845+
*
846+
* @param array $categoriesFilter
847+
*/
848+
public function addCategoriesFilter(array $categoriesFilter)
849+
{
850+
foreach ($categoriesFilter as $conditionType => $values) {
851+
$categorySelect = $this->getConnection()->select()->from(
852+
['cat' => $this->getTable('catalog_category_product')],
853+
'cat.product_id'
854+
)->where($this->getConnection()->prepareSqlCondition('cat.category_id', ['in' => $values]));
855+
$selectCondition = [
856+
$this->mapConditionType($conditionType) => $categorySelect
857+
];
858+
$this->getSelect()->where($this->getConnection()->prepareSqlCondition('e.entity_id' , $selectCondition));
859+
}
860+
}
861+
862+
/**
863+
* Map equal and not equal conditions to in and not in
864+
*
865+
* @param string $conditionType
866+
* @return mixed
867+
*/
868+
private function mapConditionType($conditionType)
869+
{
870+
$conditionsMap = [
871+
'eq' => 'in',
872+
'neq' => 'nin'
873+
];
874+
return isset($conditionsMap[$conditionType]) ? $conditionsMap[$conditionType] : $conditionType;
875+
}
876+
843877
/**
844878
* Join minimal price attribute to result
845879
*

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,21 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje
119119
$optionId = $connection->fetchOne($statement);
120120

121121
if ($optionId) {
122-
if ($object->getStoreId() == '0') {
123-
$data = $this->_prepareDataForTable(
124-
new \Magento\Framework\DataObject(
125-
['price' => $object->getPrice(), 'price_type' => $object->getPriceType()]
126-
),
127-
$priceTable
128-
);
122+
$data = $this->_prepareDataForTable(
123+
new \Magento\Framework\DataObject(
124+
['price' => $object->getPrice(), 'price_type' => $object->getPriceType()]
125+
),
126+
$priceTable
127+
);
129128

130-
$connection->update(
131-
$priceTable,
132-
$data,
133-
[
134-
'option_id = ?' => $object->getId(),
135-
'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID
136-
]
137-
);
138-
}
129+
$connection->update(
130+
$priceTable,
131+
$data,
132+
[
133+
'option_id = ?' => $object->getId(),
134+
'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID
135+
]
136+
);
139137
} else {
140138
$data = $this->_prepareDataForTable(
141139
new \Magento\Framework\DataObject(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CustomOptionPrice extends AbstractPrice implements CustomOptionPriceInterf
4141
* @param float $quantity
4242
* @param CalculatorInterface $calculator
4343
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
44-
* @param string $excludeAdjustment
44+
* @param array $excludeAdjustment
4545
*/
4646
public function __construct(
4747
SaleableInterface $saleableItem,
@@ -113,7 +113,7 @@ public function getValue()
113113

114114
/**
115115
* @param float $amount
116-
* @param null|bool|string $exclude
116+
* @param null|bool|string|array $exclude
117117
* @param null|array $context
118118
* @return AmountInterface|bool|float
119119
*/

app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,10 @@ public function testDeleteById()
553553
$this->assertTrue($this->model->deleteById($sku));
554554
}
555555

556-
public function testGetList()
556+
/**
557+
* @dataProvider fieldName
558+
*/
559+
public function testGetList($fieldName)
557560
{
558561
$searchCriteriaMock = $this->getMock('\Magento\Framework\Api\SearchCriteriaInterface', [], [], '', false);
559562
$attributeCode = 'attribute_code';
@@ -596,15 +599,14 @@ public function testGetList()
596599
$searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]);
597600
$filterGroupMock->expects($this->once())->method('getFilters')->willReturn([$filterGroupFilterMock]);
598601
$filterGroupFilterMock->expects($this->exactly(2))->method('getConditionType')->willReturn('eq');
599-
$filterGroupFilterMock->expects($this->once())->method('getField')->willReturn('field');
602+
$filterGroupFilterMock->expects($this->atLeastOnce())->method('getField')->willReturn($fieldName);
600603
$filterGroupFilterMock->expects($this->once())->method('getValue')->willReturn('value');
601-
$collectionMock->expects($this->once())->method('addFieldToFilter')
602-
->with([['attribute' => 'field', 'eq' => 'value']]);
604+
$this->expectAddToFilter($fieldName, $collectionMock);
603605
$searchCriteriaMock->expects($this->once())->method('getSortOrders')->willReturn([$sortOrderMock]);
604-
$sortOrderMock->expects($this->once())->method('getField')->willReturn('field');
606+
$sortOrderMock->expects($this->atLeastOnce())->method('getField')->willReturn($fieldName);
605607
$sortOrderMock->expects($this->once())->method('getDirection')
606608
->willReturn(SortOrder::SORT_ASC);
607-
$collectionMock->expects($this->once())->method('addOrder')->with('field', 'ASC');
609+
$collectionMock->expects($this->once())->method('addOrder')->with($fieldName, 'ASC');
608610
$searchCriteriaMock->expects($this->once())->method('getCurrentPage')->willReturn(4);
609611
$collectionMock->expects($this->once())->method('setCurPage')->with(4);
610612
$searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(42);
@@ -1199,4 +1201,31 @@ public function testSaveExistingWithMediaGalleryEntries()
11991201
$this->model->save($this->productMock);
12001202
$this->assertEquals($expectedResult, $this->initializedProductMock->getMediaGallery('images'));
12011203
}
1204+
1205+
/**
1206+
* @param $fieldName
1207+
* @param $collectionMock
1208+
* @return void
1209+
*/
1210+
public function expectAddToFilter($fieldName, $collectionMock)
1211+
{
1212+
if ($fieldName == 'category_id') {
1213+
$collectionMock->expects($this->once())->method('addCategoriesFilter')
1214+
->with(['eq' => ['value']]);
1215+
} else {
1216+
$collectionMock->expects($this->once())->method('addFieldToFilter')
1217+
->with([['attribute' => $fieldName, 'eq' => 'value']]);
1218+
}
1219+
}
1220+
1221+
/**
1222+
* @return array
1223+
*/
1224+
public function fieldName()
1225+
{
1226+
return [
1227+
['category_id'],
1228+
['field']
1229+
];
1230+
}
12021231
}

0 commit comments

Comments
 (0)