Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 4cd397d

Browse files
Andrei_MaletsAndrei_Malets
authored andcommitted
Merge branch '2.2-develop' into PerformanceToolkitUpdate
2 parents 4273793 + 28d4287 commit 4cd397d

File tree

37 files changed

+1362
-153
lines changed

37 files changed

+1362
-153
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/CatalogImportExport/Model/Export/Product.php

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
153153
/**
154154
* Items per page for collection limitation
155155
*
156-
* @var null
156+
* @var int|null
157157
*/
158158
protected $_itemsPerPage = null;
159159

160160
/**
161161
* Header columns for export file
162162
*
163163
* @var array
164+
* @deprecated
164165
*/
165166
protected $_headerColumns = [];
166167

@@ -234,17 +235,15 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
234235
protected $_fieldsMap = [
235236
'image' => 'base_image',
236237
'image_label' => "base_image_label",
237-
'image' => 'base_image',
238-
'image_label' => 'base_image_label',
239238
'thumbnail' => 'thumbnail_image',
240239
'thumbnail_label' => 'thumbnail_image_label',
241240
self::COL_MEDIA_IMAGE => 'additional_images',
242241
'_media_image_label' => 'additional_image_labels',
243-
Product::COL_STORE => 'store_view_code',
244-
Product::COL_ATTR_SET => 'attribute_set_code',
245-
Product::COL_TYPE => 'product_type',
246-
Product::COL_CATEGORY => 'categories',
247-
Product::COL_PRODUCT_WEBSITES => 'product_websites',
242+
self::COL_STORE => 'store_view_code',
243+
self::COL_ATTR_SET => 'attribute_set_code',
244+
self::COL_TYPE => 'product_type',
245+
self::COL_CATEGORY => 'categories',
246+
self::COL_PRODUCT_WEBSITES => 'product_websites',
248247
'status' => 'product_online',
249248
'news_from_date' => 'new_from_date',
250249
'news_to_date' => 'new_to_date',
@@ -691,7 +690,7 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
691690
*/
692691
public function _getHeaderColumns()
693692
{
694-
return $this->_customHeadersMapping($this->_headerColumns);
693+
return $this->_customHeadersMapping($this->rowCustomizer->addHeaderColumns($this->_headerColumns));
695694
}
696695

697696
/**
@@ -700,13 +699,13 @@ public function _getHeaderColumns()
700699
* @param array $customOptionsData
701700
* @param array $stockItemRows
702701
* @return void
702+
* @deprecated Logic will be moved to _getHeaderColumns in future release
703+
*
704+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
703705
*/
704706
protected function setHeaderColumns($customOptionsData, $stockItemRows)
705707
{
706708
if (!$this->_headerColumns) {
707-
$customOptCols = [
708-
'custom_options',
709-
];
710709
$this->_headerColumns = array_merge(
711710
[
712711
self::COL_SKU,
@@ -719,21 +718,19 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
719718
$this->_getExportMainAttrCodes(),
720719
[self::COL_ADDITIONAL_ATTRIBUTES],
721720
reset($stockItemRows) ? array_keys(end($stockItemRows)) : [],
722-
[],
723721
[
724722
'related_skus',
725723
'related_position',
726724
'crosssell_skus',
727725
'crosssell_position',
728726
'upsell_skus',
729-
'upsell_position'
730-
],
731-
['additional_images', 'additional_image_labels', 'hide_from_product_page']
727+
'upsell_position',
728+
'additional_images',
729+
'additional_image_labels',
730+
'hide_from_product_page',
731+
'custom_options'
732+
]
732733
);
733-
// have we merge custom options columns
734-
if ($customOptionsData) {
735-
$this->_headerColumns = array_merge($this->_headerColumns, $customOptCols);
736-
}
737734
}
738735
}
739736

@@ -892,10 +889,12 @@ protected function getExportData()
892889
$productIds = array_keys($rawData);
893890
$stockItemRows = $this->prepareCatalogInventory($productIds);
894891

895-
$this->rowCustomizer->prepareData($this->_getEntityCollection(), $productIds);
892+
$this->rowCustomizer->prepareData(
893+
$this->_prepareEntityCollection($this->_entityCollectionFactory->create()),
894+
$productIds
895+
);
896896

897897
$this->setHeaderColumns($multirawData['customOptionsData'], $stockItemRows);
898-
$this->_headerColumns = $this->rowCustomizer->addHeaderColumns($this->_headerColumns);
899898

900899
foreach ($rawData as $productId => $productData) {
901900
foreach ($productData as $storeId => $dataRow) {
@@ -1231,9 +1230,6 @@ private function appendMultirowData(&$dataRow, &$multiRawData)
12311230
return null;
12321231
} elseif ($storeId != Store::DEFAULT_STORE_ID) {
12331232
$dataRow[self::COL_STORE] = $this->_storeIdToCode[$storeId];
1234-
if (isset($productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY])) {
1235-
$dataRow[self::COL_VISIBILITY] = $productData[Store::DEFAULT_STORE_ID][self::COL_VISIBILITY];
1236-
}
12371233
}
12381234
$dataRow[self::COL_SKU] = $sku;
12391235
return $dataRow;

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,15 @@ public function testGetHeaderColumns()
270270
$headerColumnsValue = ['headerColumns value'];
271271
$expectedResult = 'result';
272272
$this->setPropertyValue($product, '_headerColumns', $headerColumnsValue);
273-
$product
274-
->expects($this->once())
273+
$this->setPropertyValue($product, 'rowCustomizer', $this->rowCustomizer);
274+
$product->expects($this->once())
275275
->method('_customHeadersMapping')
276276
->with($headerColumnsValue)
277277
->willReturn($expectedResult);
278+
$this->rowCustomizer->expects($this->once())
279+
->method('addHeaderColumns')
280+
->with($headerColumnsValue)
281+
->willReturn($headerColumnsValue);
278282

279283
$result = $product->_getHeaderColumns();
280284

app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Attribute.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function beforeSave(
5656
) {
5757
$this->saveIsNew = $attribute->isObjectNew();
5858
$this->saveNeedInvalidation = (
59-
$attribute->dataHasChangedFor('is_searchable')
60-
|| $attribute->dataHasChangedFor('is_filterable')
61-
|| $attribute->dataHasChangedFor('is_visible_in_advanced_search')
62-
) && ! $this->saveIsNew;
59+
$attribute->dataHasChangedFor('is_searchable')
60+
|| $attribute->dataHasChangedFor('is_filterable')
61+
|| $attribute->dataHasChangedFor('is_visible_in_advanced_search')
62+
);
6363
}
6464

6565
/**

0 commit comments

Comments
 (0)