Skip to content

Commit bc71cd3

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into develop-prs
2 parents 37c47fa + 59fb155 commit bc71cd3

File tree

28 files changed

+547
-93
lines changed

28 files changed

+547
-93
lines changed

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,32 @@
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
10+
use Magento\Framework\Stdlib\ArrayManager;
1011

1112
/**
1213
* Customize Advanced Pricing modal panel
1314
*/
1415
class BundleAdvancedPricing extends AbstractModifier
1516
{
17+
const CODE_PRICE_TYPE = 'price_type';
1618
const CODE_MSRP = 'msrp';
1719
const CODE_MSRP_DISPLAY_ACTUAL_PRICE_TYPE = 'msrp_display_actual_price_type';
1820
const CODE_ADVANCED_PRICING = 'advanced-pricing';
1921
const CODE_RECORD = 'record';
2022

23+
/**
24+
* @var ArrayManager
25+
*/
26+
private $arrayManager;
27+
28+
/**
29+
* @param ArrayManager $arrayManager
30+
*/
31+
public function __construct(ArrayManager $arrayManager)
32+
{
33+
$this->arrayManager = $arrayManager;
34+
}
35+
2136
/**
2237
* {@inheritdoc}
2338
*/
@@ -29,8 +44,7 @@ public function modifyMeta(array $meta)
2944
if (isset($parentNode['container_' . self::CODE_MSRP])
3045
&& isset($parentNode['container_' . self::CODE_MSRP_DISPLAY_ACTUAL_PRICE_TYPE])
3146
) {
32-
unset($parentNode['container_' . self::CODE_MSRP]);
33-
unset($parentNode['container_' . self::CODE_MSRP_DISPLAY_ACTUAL_PRICE_TYPE]);
47+
$parentNode = $this->modifyMsrpMeta($parentNode);
3448
}
3549
if (isset($parentNode['container_' . ProductAttributeInterface::CODE_SPECIAL_PRICE])) {
3650
$currentNode = &$parentNode['container_' . ProductAttributeInterface::CODE_SPECIAL_PRICE]['children'];
@@ -55,4 +69,45 @@ public function modifyData(array $data)
5569
{
5670
return $data;
5771
}
72+
73+
/**
74+
* Modify meta for MSRP fields.
75+
*
76+
* @param array $meta
77+
* @return array
78+
*/
79+
private function modifyMsrpMeta(array $meta)
80+
{
81+
$meta = $this->arrayManager->merge(
82+
$this->arrayManager->findPath(
83+
static::CODE_MSRP,
84+
$meta,
85+
null,
86+
'children'
87+
) . static::META_CONFIG_PATH,
88+
$meta,
89+
[
90+
'imports' => [
91+
'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked'
92+
]
93+
]
94+
);
95+
96+
$meta = $this->arrayManager->merge(
97+
$this->arrayManager->findPath(
98+
static::CODE_MSRP_DISPLAY_ACTUAL_PRICE_TYPE,
99+
$meta,
100+
null,
101+
'children'
102+
) . static::META_CONFIG_PATH,
103+
$meta,
104+
[
105+
'imports' => [
106+
'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked'
107+
]
108+
]
109+
);
110+
111+
return $meta;
112+
}
58113
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private function cacheProduct($cacheKey, \Magento\Catalog\Api\Data\ProductInterf
308308

309309
if ($this->cacheLimit && count($this->instances) > $this->cacheLimit) {
310310
$offset = round($this->cacheLimit / -2);
311-
$this->instancesById = array_slice($this->instancesById, $offset);
311+
$this->instancesById = array_slice($this->instancesById, $offset, null, true);
312312
$this->instances = array_slice($this->instances, $offset);
313313
}
314314
}

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase
153153
*/
154154
private $serializerMock;
155155

156+
/**
157+
* Product repository cache limit.
158+
*
159+
* @var int
160+
*/
161+
private $cacheLimit = 2;
162+
156163
/**
157164
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
158165
*/
@@ -337,6 +344,7 @@ function ($value) {
337344
'mediaGalleryProcessor' => $this->mediaGalleryProcessor,
338345
'collectionProcessor' => $this->collectionProcessorMock,
339346
'serializer' => $this->serializerMock,
347+
'cacheLimit' => $this->cacheLimit
340348
]
341349
);
342350
}
@@ -469,6 +477,61 @@ public function testGetByIdForcedReload()
469477
$this->assertEquals($this->productMock, $this->model->getById($identifier, $editMode, $storeId, true));
470478
}
471479

480+
/**
481+
* Test for getById() method if we try to get products when cache is already filled and is reduced.
482+
*
483+
* @return void
484+
*/
485+
public function testGetByIdWhenCacheReduced()
486+
{
487+
$result = [];
488+
$expectedResult = [];
489+
$productsCount = $this->cacheLimit * 2;
490+
491+
$productMocks = $this->getProductMocksForReducedCache($productsCount);
492+
$productFactoryInvMock = $this->productFactoryMock->expects($this->exactly($productsCount))
493+
->method('create');
494+
call_user_func_array([$productFactoryInvMock, 'willReturnOnConsecutiveCalls'], $productMocks);
495+
$this->serializerMock->expects($this->atLeastOnce())->method('serialize');
496+
497+
for ($i = 1; $i <= $productsCount; $i++) {
498+
$product = $this->model->getById($i, false, 0);
499+
$result[] = $product->getId();
500+
$expectedResult[] = $i;
501+
}
502+
503+
$this->assertEquals($expectedResult, $result);
504+
}
505+
506+
/**
507+
* Get product mocks for testGetByIdWhenCacheReduced() method.
508+
*
509+
* @param int $productsCount
510+
* @return array
511+
*/
512+
private function getProductMocksForReducedCache($productsCount)
513+
{
514+
$productMocks = [];
515+
516+
for ($i = 1; $i <= $productsCount; $i++) {
517+
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
518+
->disableOriginalConstructor()
519+
->setMethods([
520+
'getId',
521+
'getSku',
522+
'load',
523+
'setData',
524+
])
525+
->getMock();
526+
$productMock->expects($this->once())->method('load');
527+
$productMock->expects($this->atLeastOnce())->method('getId')->willReturn($i);
528+
$productMock->expects($this->atLeastOnce())->method('getSku')->willReturn($i . uniqid());
529+
$productMocks[] = $productMock;
530+
}
531+
532+
return $productMocks;
533+
}
534+
472535
/**
473536
* Test forceReload parameter
474537
*

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,6 @@ protected function _renderFiltersBefore()
362362
[]
363363
);
364364

365-
$this->_totalRecords = $this->searchResult->getTotalCount();
366-
367365
if ($this->order && 'relevance' === $this->order['field']) {
368366
$this->getSelect()->order('search_result.'. TemporaryStorage::FIELD_SCORE . ' ' . $this->order['dir']);
369367
}

app/code/Magento/Customer/Model/Address.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,14 @@ private function getAttributeList()
378378
}
379379
return $this->attributeList;
380380
}
381+
382+
/**
383+
* Retrieve attribute set id for customer address.
384+
*
385+
* @return int
386+
*/
387+
public function getAttributeSetId()
388+
{
389+
return parent::getAttributeSetId() ?: AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS;
390+
}
381391
}

app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@ class Export extends ExportController
2020
*/
2121
protected $fileFactory;
2222

23+
/**
24+
* @var \Magento\Framework\Session\SessionManagerInterface
25+
*/
26+
private $sessionManager;
27+
2328
/**
2429
* @param \Magento\Backend\App\Action\Context $context
2530
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
31+
* @param \Magento\Framework\Session\SessionManagerInterface $sessionManager [optional]
2632
*/
2733
public function __construct(
2834
Context $context,
29-
FileFactory $fileFactory
35+
FileFactory $fileFactory,
36+
\Magento\Framework\Session\SessionManagerInterface $sessionManager = null
3037
) {
3138
$this->fileFactory = $fileFactory;
39+
$this->sessionManager = $sessionManager ?: \Magento\Framework\App\ObjectManager::getInstance()
40+
->get(\Magento\Framework\Session\SessionManagerInterface::class);
3241
parent::__construct($context);
3342
}
3443

@@ -45,6 +54,7 @@ public function execute()
4554
$model = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class);
4655
$model->setData($this->getRequest()->getParams());
4756

57+
$this->sessionManager->writeClose();
4858
return $this->fileFactory->create(
4959
$model->getFileName(),
5060
$model->export(),

app/code/Magento/Sales/Model/ResourceModel/Report/Invoiced/Collection/Invoiced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
\Magento\Sales\Model\ResourceModel\Report $resource,
2929
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
3030
) {
31-
$resource->init('sales_invoiced_aggregated');
3231
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $resource, $connection);
32+
$resource->init('sales_invoiced_aggregated');
3333
}
3434
}

app/code/Magento/Sales/Model/ResourceModel/Report/Invoiced/Collection/Order.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,12 @@ protected function _getSelectedColumns()
8383
return $this->_selectedColumns;
8484
}
8585

86-
/**
87-
* Add selected data
88-
*
89-
* @return $this
90-
*/
91-
protected function _initSelect()
92-
{
93-
$this->getSelect()->from($this->getResource()->getMainTable());
94-
return parent::_initSelect();
95-
}
96-
9786
/**
9887
* @return $this
9988
*/
10089
protected function _beforeLoad()
10190
{
102-
$this->getSelect()->columns($this->_getSelectedColumns());
91+
$this->getSelect()->from($this->getResource()->getMainTable(), $this->_getSelectedColumns());
10392
if (!$this->isTotals()) {
10493
$this->getSelect()->group($this->_periodFormat);
10594
$this->getSelect()->having('SUM(orders_count) > 0');

app/code/Magento/Sales/Model/ResourceModel/Report/Refunded/Collection/Refunded.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
\Magento\Sales\Model\ResourceModel\Report $resource,
2929
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
3030
) {
31-
$resource->init('sales_refunded_aggregated');
3231
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $resource, $connection);
32+
$resource->init('sales_refunded_aggregated');
3333
}
3434
}

app/code/Magento/Sales/Model/ResourceModel/Report/Shipping/Collection/Shipment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
\Magento\Sales\Model\ResourceModel\Report $resource,
2929
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
3030
) {
31-
$resource->init('sales_shipping_aggregated');
3231
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $resource, $connection);
32+
$resource->init('sales_shipping_aggregated');
3333
}
3434
}

0 commit comments

Comments
 (0)