Skip to content

Commit bc1dfc9

Browse files
author
Eric Bohanon
committed
Merge remote-tracking branches 'remotes/origin/MAGETWO-71648-Unnecessary-Temp-Table-Removal' and 'remotes/origin/MAGETWO-71656-OOS-Config-Prod-Show-On-Save' into Okapis-2-2-Release-Branch
2 parents 8c64127 + d34a471 commit bc1dfc9

File tree

80 files changed

+2943
-342
lines changed

Some content is hidden

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

80 files changed

+2943
-342
lines changed

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function getDefaultValues()
142142
*/
143143
protected function _getSelectedOptions()
144144
{
145-
if (is_null($this->_selectedOptions)) {
145+
if ($this->_selectedOptions === null) {
146146
$this->_selectedOptions = [];
147147

148148
/** @var \Magento\Bundle\Model\Option $option */
@@ -152,17 +152,29 @@ protected function _getSelectedOptions()
152152
$selectionId = $this->getProduct()->getPreconfiguredValues()->getData(
153153
'bundle_option/' . $option->getId()
154154
);
155-
if ($selectionId && $option->getSelectionById($selectionId)) {
156-
$this->_selectedOptions = $selectionId;
157-
} elseif (!$option->getRequired()) {
158-
$this->_selectedOptions = 'None';
159-
}
155+
$this->assignSelection($option, $selectionId);
160156
}
161157
}
162158

163159
return $this->_selectedOptions;
164160
}
165161

162+
/**
163+
* Set selected options.
164+
*
165+
* @param \Magento\Bundle\Model\Option $option
166+
* @param mixed $selectionId
167+
* @return void
168+
*/
169+
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
170+
{
171+
if ($selectionId && $option->getSelectionById($selectionId)) {
172+
$this->_selectedOptions = $selectionId;
173+
} elseif (!$option->getRequired()) {
174+
$this->_selectedOptions = 'None';
175+
}
176+
}
177+
166178
/**
167179
* Define if selection is selected
168180
*

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,20 @@ class Multi extends \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Optio
1717
* @var string
1818
*/
1919
protected $_template = 'catalog/product/view/type/bundle/option/multi.phtml';
20+
21+
/**
22+
* @inheritdoc
23+
*/
24+
protected function assignSelection(\Magento\Bundle\Model\Option $option, $selectionId)
25+
{
26+
if (is_array($selectionId)) {
27+
foreach ($selectionId as $id) {
28+
if ($id && $option->getSelectionById($id)) {
29+
$this->_selectedOptions[] = $id;
30+
}
31+
}
32+
} else {
33+
parent::assignSelection($option, $selectionId);
34+
}
35+
}
2036
}

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/Bundle/view/frontend/templates/catalog/product/view/type/bundle/options.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
<?php
1212
$product = $block->getProduct();
1313
$helper = $this->helper('Magento\Catalog\Helper\Output');
14+
$stripSelection = $product->getConfigureMode() ? true : false;
15+
$options = $block->decorateArray($block->getOptions($stripSelection));
1416
?>
15-
<?php $options = $block->decorateArray($block->getOptions()); ?>
1617
<?php if ($product->isSaleable()):?>
1718
<?php if (count($options)): ?>
1819
<script type="text/x-magento-init">

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
namespace Magento\Catalog\Controller\Adminhtml\Product;
88

99
use Magento\Framework\Controller\ResultFactory;
10-
use Magento\Catalog\Controller\Adminhtml\Product\Builder;
1110
use Magento\Backend\App\Action\Context;
1211
use Magento\Ui\Component\MassAction\Filter;
1312
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
13+
use Magento\Catalog\Api\ProductRepositoryInterface;
1414

1515
class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
1616
{
@@ -26,20 +26,29 @@ class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
2626
*/
2727
protected $collectionFactory;
2828

29+
/**
30+
* @var ProductRepositoryInterface
31+
*/
32+
private $productRepository;
33+
2934
/**
3035
* @param Context $context
3136
* @param Builder $productBuilder
3237
* @param Filter $filter
3338
* @param CollectionFactory $collectionFactory
39+
* @param ProductRepositoryInterface $productRepository
3440
*/
3541
public function __construct(
3642
Context $context,
3743
Builder $productBuilder,
3844
Filter $filter,
39-
CollectionFactory $collectionFactory
45+
CollectionFactory $collectionFactory,
46+
ProductRepositoryInterface $productRepository = null
4047
) {
4148
$this->filter = $filter;
4249
$this->collectionFactory = $collectionFactory;
50+
$this->productRepository = $productRepository
51+
?: \Magento\Framework\App\ObjectManager::getInstance()->create(ProductRepositoryInterface::class);
4352
parent::__construct($context, $productBuilder);
4453
}
4554

@@ -50,8 +59,9 @@ public function execute()
5059
{
5160
$collection = $this->filter->getCollection($this->collectionFactory->create());
5261
$productDeleted = 0;
62+
/** @var \Magento\Catalog\Model\Product $product */
5363
foreach ($collection->getItems() as $product) {
54-
$product->delete();
64+
$this->productRepository->delete($product);
5565
$productDeleted++;
5666
}
5767
$this->messageManager->addSuccess(
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model\Indexer\Product;
8+
9+
use Magento\Framework\Indexer\ActionInterface;
10+
use Magento\Framework\Indexer\IndexerRegistry;
11+
12+
/**
13+
* Reindex all relevant product indexers
14+
*/
15+
class Full implements ActionInterface
16+
{
17+
/**
18+
* @var IndexerRegistry
19+
*/
20+
private $indexerRegistry;
21+
22+
/**
23+
* @var string[]
24+
*/
25+
private $indexerList;
26+
27+
/**
28+
* Initialize dependencies
29+
*
30+
* @param IndexerRegistry $indexerRegistry
31+
* @param string[] $indexerList
32+
*/
33+
public function __construct(
34+
IndexerRegistry $indexerRegistry,
35+
array $indexerList
36+
) {
37+
$this->indexerRegistry = $indexerRegistry;
38+
$this->indexerList = $indexerList;
39+
}
40+
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public function executeFull()
45+
{
46+
foreach ($this->indexerList as $indexerName) {
47+
$indexer = $this->indexerRegistry->get($indexerName);
48+
if (!$indexer->isScheduled()) {
49+
$indexer->reindexAll();
50+
}
51+
}
52+
}
53+
54+
/**
55+
* {@inheritdoc}
56+
*/
57+
public function executeList(array $ids)
58+
{
59+
if (!empty($ids)) {
60+
foreach ($this->indexerList as $indexerName) {
61+
$indexer = $this->indexerRegistry->get($indexerName);
62+
if (!$indexer->isScheduled()) {
63+
$indexer->reindexList($ids);
64+
}
65+
}
66+
}
67+
}
68+
69+
/**
70+
* {@inheritDoc}
71+
*/
72+
public function executeRow($id)
73+
{
74+
if (!empty($id)) {
75+
foreach ($this->indexerList as $indexerName) {
76+
$indexer = $this->indexerRegistry->get($indexerName);
77+
if (!$indexer->isScheduled()) {
78+
$indexer->reindexRow($id);
79+
}
80+
}
81+
}
82+
}
83+
}

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

0 commit comments

Comments
 (0)