Skip to content

Commit 817a068

Browse files
committed
Merge remote-tracking branch 'origin/2.3-develop' into MAGETWO-89417
2 parents c577e53 + 2f6cb7d commit 817a068

File tree

42 files changed

+671
-246
lines changed

Some content is hidden

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

42 files changed

+671
-246
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
use Magento\Backend\Block\Widget\Grid;
1515
use Magento\Backend\Block\Widget\Grid\Column;
1616
use Magento\Backend\Block\Widget\Grid\Extended;
17+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
18+
use Magento\Catalog\Model\Product\Visibility;
19+
use Magento\Framework\App\ObjectManager;
1720

1821
class Product extends \Magento\Backend\Block\Widget\Grid\Extended
1922
{
@@ -29,22 +32,38 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
2932
*/
3033
protected $_productFactory;
3134

35+
/**
36+
* @var Status
37+
*/
38+
private $status;
39+
40+
/**
41+
* @var Visibility
42+
*/
43+
private $visibility;
44+
3245
/**
3346
* @param \Magento\Backend\Block\Template\Context $context
3447
* @param \Magento\Backend\Helper\Data $backendHelper
3548
* @param \Magento\Catalog\Model\ProductFactory $productFactory
3649
* @param \Magento\Framework\Registry $coreRegistry
3750
* @param array $data
51+
* @param Visibility|null $visibility
52+
* @param Status|null $status
3853
*/
3954
public function __construct(
4055
\Magento\Backend\Block\Template\Context $context,
4156
\Magento\Backend\Helper\Data $backendHelper,
4257
\Magento\Catalog\Model\ProductFactory $productFactory,
4358
\Magento\Framework\Registry $coreRegistry,
44-
array $data = []
59+
array $data = [],
60+
Visibility $visibility = null,
61+
Status $status = null
4562
) {
4663
$this->_productFactory = $productFactory;
4764
$this->_coreRegistry = $coreRegistry;
65+
$this->visibility = $visibility ?: ObjectManager::getInstance()->get(Visibility::class);
66+
$this->status = $status ?: ObjectManager::getInstance()->get(Status::class);
4867
parent::__construct($context, $backendHelper, $data);
4968
}
5069

@@ -102,6 +121,10 @@ protected function _prepareCollection()
102121
'name'
103122
)->addAttributeToSelect(
104123
'sku'
124+
)->addAttributeToSelect(
125+
'visibility'
126+
)->addAttributeToSelect(
127+
'status'
105128
)->addAttributeToSelect(
106129
'price'
107130
)->joinField(
@@ -159,6 +182,28 @@ protected function _prepareColumns()
159182
);
160183
$this->addColumn('name', ['header' => __('Name'), 'index' => 'name']);
161184
$this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
185+
$this->addColumn(
186+
'visibility',
187+
[
188+
'header' => __('Visibility'),
189+
'index' => 'visibility',
190+
'type' => 'options',
191+
'options' => $this->visibility->getOptionArray(),
192+
'header_css_class' => 'col-visibility',
193+
'column_css_class' => 'col-visibility'
194+
]
195+
);
196+
197+
$this->addColumn(
198+
'status',
199+
[
200+
'header' => __('Status'),
201+
'index' => 'status',
202+
'type' => 'options',
203+
'options' => $this->status->getOptionArray()
204+
]
205+
);
206+
162207
$this->addColumn(
163208
'price',
164209
[

app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Full.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -115,47 +115,6 @@ public function execute()
115115
return $this;
116116
}
117117

118-
/**
119-
* Return select for remove unnecessary data
120-
*
121-
* @return \Magento\Framework\DB\Select
122-
*
123-
* @deprecated Not used anymore.
124-
* @see clearCurrentTable()
125-
*/
126-
protected function getSelectUnnecessaryData()
127-
{
128-
return $this->connection->select()->from(
129-
$this->getMainTable(),
130-
[]
131-
)->joinLeft(
132-
['t' => $this->getMainTable()],
133-
$this->getMainTable() .
134-
'.category_id = t.category_id AND ' .
135-
$this->getMainTable() .
136-
'.store_id = t.store_id AND ' .
137-
$this->getMainTable() .
138-
'.product_id = t.product_id',
139-
[]
140-
)->where(
141-
't.category_id IS NULL'
142-
);
143-
}
144-
145-
/**
146-
* Remove unnecessary data
147-
*
148-
* @return void
149-
*
150-
* @deprecated Not used anymore.
151-
* @see clearCurrentTable()
152-
*/
153-
protected function removeUnnecessaryData()
154-
{
155-
//Called for backward compatibility.
156-
$this->getSelectUnnecessaryData();
157-
}
158-
159118
/**
160119
* Publish data from tmp to index
161120
*
@@ -254,8 +213,6 @@ private function reindexCategoriesBySelect(\Magento\Framework\DB\Select $basicSe
254213
)
255214
);
256215
$this->publishData();
257-
//Called for backward compatibility.
258-
$this->removeUnnecessaryData();
259216
}
260217
}
261218
}

app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,10 @@
4040
</div>
4141
</div>
4242
<?php endif; ?>
43-
<?php if ($block->isRedirectToCartEnabled()) : ?>
44-
<script type="text/x-magento-init">
45-
{
46-
"#product_addtocart_form": {
47-
"Magento_Catalog/product/view/validation": {
48-
"radioCheckboxClosest": ".nested"
49-
}
50-
}
51-
}
52-
</script>
53-
<?php else : ?>
5443
<script type="text/x-magento-init">
5544
{
5645
"#product_addtocart_form": {
5746
"Magento_Catalog/js/validate-product": {}
5847
}
5948
}
6049
</script>
61-
<?php endif; ?>

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ public function validate(Observer $observer)
104104
$quoteItem = $observer->getEvent()->getItem();
105105
if (!$quoteItem ||
106106
!$quoteItem->getProductId() ||
107-
!$quoteItem->getQuote() ||
108-
$quoteItem->getQuote()->getIsSuperMode()
107+
!$quoteItem->getQuote()
109108
) {
110109
return;
111110
}
@@ -118,6 +117,18 @@ public function validate(Observer $observer)
118117
throw new LocalizedException(__('The Product stock item is invalid. Verify the stock item and try again.'));
119118
}
120119

120+
if (($options = $quoteItem->getQtyOptions()) && $qty > 0) {
121+
foreach ($options as $option) {
122+
$this->optionInitializer->initialize($option, $quoteItem, $qty);
123+
}
124+
} else {
125+
$this->stockItemInitializer->initialize($stockItem, $quoteItem, $qty);
126+
}
127+
128+
if ($quoteItem->getQuote()->getIsSuperMode()) {
129+
return;
130+
}
131+
121132
/* @var \Magento\CatalogInventory\Api\Data\StockStatusInterface $stockStatus */
122133
$stockStatus = $this->stockRegistry->getStockStatus($product->getId(), $product->getStore()->getWebsiteId());
123134

@@ -160,7 +171,7 @@ public function validate(Observer $observer)
160171
/**
161172
* Check item for options
162173
*/
163-
if (($options = $quoteItem->getQtyOptions()) && $qty > 0) {
174+
if ($options) {
164175
$qty = $product->getTypeInstance()->prepareQuoteItemQty($qty, $product);
165176
$quoteItem->setData('qty', $qty);
166177
if ($stockStatus) {
@@ -194,7 +205,7 @@ public function validate(Observer $observer)
194205
$removeError = true;
195206

196207
foreach ($options as $option) {
197-
$result = $this->optionInitializer->initialize($option, $quoteItem, $qty);
208+
$result = $option->getStockStateResult();
198209
if ($result->getHasError()) {
199210
$option->setHasError(true);
200211
//Setting this to false, so no error statuses are cleared
@@ -207,7 +218,7 @@ public function validate(Observer $observer)
207218
}
208219
} else {
209220
if ($quoteItem->getParentItem() === null) {
210-
$result = $this->stockItemInitializer->initialize($stockItem, $quoteItem, $qty);
221+
$result = $quoteItem->getStockStateResult();
211222
if ($result->getHasError()) {
212223
$this->addErrorInfoToQuote($result, $quoteItem);
213224
} else {

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/Option.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public function initialize(
133133

134134
$stockItem->unsIsChildItem();
135135

136+
$option->setStockStateResult($result);
137+
136138
return $result;
137139
}
138140
}

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator/Initializer/StockItem.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ public function initialize(
135135
$quoteItem->setBackorders($result->getItemBackorders());
136136
}
137137

138+
$quoteItem->setStockStateResult($result);
139+
138140
return $result;
139141
}
140142
}

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ public function testValidateWithOptions()
278278
{
279279
$optionMock = $this->getMockBuilder(OptionItem::class)
280280
->disableOriginalConstructor()
281-
->setMethods(['setHasError'])
281+
->setMethods(['setHasError', 'getStockStateResult'])
282282
->getMock();
283+
$optionMock->expects($this->once())
284+
->method('getStockStateResult')
285+
->willReturn($this->resultMock);
283286
$this->stockRegistryMock->expects($this->at(0))
284287
->method('getStockItem')
285288
->willReturn($this->stockItemMock);
@@ -316,14 +319,17 @@ public function testValidateWithOptionsAndError()
316319
{
317320
$optionMock = $this->getMockBuilder(OptionItem::class)
318321
->disableOriginalConstructor()
319-
->setMethods(['setHasError'])
322+
->setMethods(['setHasError', 'getStockStateResult'])
320323
->getMock();
321324
$this->stockRegistryMock->expects($this->at(0))
322325
->method('getStockItem')
323326
->willReturn($this->stockItemMock);
324327
$this->stockRegistryMock->expects($this->at(1))
325328
->method('getStockStatus')
326329
->willReturn($this->stockStatusMock);
330+
$optionMock->expects($this->once())
331+
->method('getStockStateResult')
332+
->willReturn($this->resultMock);
327333
$options = [$optionMock];
328334
$this->createInitialStub(1);
329335
$this->setUpStubForQuantity(1, true);
@@ -354,12 +360,15 @@ public function testValidateAndRemoveErrorsFromQuote()
354360
{
355361
$optionMock = $this->getMockBuilder(OptionItem::class)
356362
->disableOriginalConstructor()
357-
->setMethods(['setHasError'])
363+
->setMethods(['setHasError', 'getStockStateResult'])
358364
->getMock();
359365
$quoteItem = $this->getMockBuilder(Item::class)
360366
->disableOriginalConstructor()
361367
->setMethods(['getItemId', 'getErrorInfos'])
362368
->getMock();
369+
$optionMock->expects($this->once())
370+
->method('getStockStateResult')
371+
->willReturn($this->resultMock);
363372
$this->stockRegistryMock->expects($this->at(0))
364373
->method('getStockItem')
365374
->willReturn($this->stockItemMock);

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/StockItemTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function testInitializeWithSubitem()
8484
'setMessage',
8585
'setBackorders',
8686
'__wakeup',
87+
'setStockStateResult'
8788
]
8889
)
8990
->disableOriginalConstructor()
@@ -178,6 +179,7 @@ public function testInitializeWithSubitem()
178179
$quoteItem->expects($this->once())->method('setMessage')->with('message')->will($this->returnSelf());
179180
$result->expects($this->exactly(2))->method('getItemBackorders')->will($this->returnValue('backorders'));
180181
$quoteItem->expects($this->once())->method('setBackorders')->with('backorders')->will($this->returnSelf());
182+
$quoteItem->expects($this->once())->method('setStockStateResult')->with($result)->will($this->returnSelf());
181183

182184
$this->model->initialize($stockItem, $quoteItem, $qty);
183185
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ protected function _construct()
7373
* Reset search results cache
7474
*
7575
* @return $this
76+
* @deprecated Not used anymore
77+
* @see \Magento\CatalogSearch\Model\ResourceModel\Fulltext::resetSearchResultsByStore
7678
*/
7779
public function resetSearchResults()
7880
{

0 commit comments

Comments
 (0)