Skip to content

Commit 21a819d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-90286' into 2.3-develop-pr16
2 parents 1c03283 + c38562b commit 21a819d

File tree

83 files changed

+1775
-598
lines changed

Some content is hidden

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

83 files changed

+1775
-598
lines changed

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Serialize\Serializer\Json;
1313
use Magento\Framework\EntityManager\MetadataPool;
1414
use Magento\Bundle\Model\ResourceModel\Selection\Collection\FilterApplier as SelectionCollectionFilterApplier;
15+
use Magento\Bundle\Model\ResourceModel\Selection\Collection as Selections;
1516

1617
/**
1718
* Bundle Type Model
@@ -484,7 +485,9 @@ public function getSelectionsCollection($optionIds, $product)
484485
\Magento\Catalog\Api\Data\ProductInterface::class
485486
);
486487

487-
$selectionsCollection = $this->_bundleCollection->create()
488+
/** @var Selections $selectionsCollection */
489+
$selectionsCollection = $this->_bundleCollection->create();
490+
$selectionsCollection
488491
->addAttributeToSelect($this->_config->getProductAttributes())
489492
->addAttributeToSelect('tax_class_id') //used for calculation item taxes in Bundle with Dynamic Price
490493
->setFlag('product_children', true)
@@ -853,8 +856,9 @@ public function getSelectionsByIds($selectionIds, $product)
853856

854857
if (!$usedSelections || $usedSelectionsIds !== $selectionIds) {
855858
$storeId = $product->getStoreId();
856-
$usedSelections = $this->_bundleCollection
857-
->create()
859+
/** @var Selections $usedSelections */
860+
$usedSelections = $this->_bundleCollection->create();
861+
$usedSelections
858862
->addAttributeToSelect('*')
859863
->setFlag('product_children', true)
860864
->addStoreFilter($this->getStoreFilter($product))

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,36 @@ public function setPositionOrder()
163163
}
164164

165165
/**
166-
* Add filtering of product then havent enoght stock
166+
* Add filtering of products that have 0 items left.
167167
*
168168
* @return $this
169169
* @since 100.2.0
170170
*/
171171
public function addQuantityFilter()
172172
{
173+
$stockItemTable = $this->getTable('cataloginventory_stock_item');
174+
$stockStatusTable = $this->getTable('cataloginventory_stock_status');
173175
$this->getSelect()
174176
->joinInner(
175-
['stock' => $this->getTable('cataloginventory_stock_status')],
177+
['stock' => $stockStatusTable],
176178
'selection.product_id = stock.product_id',
177179
[]
180+
)->joinInner(
181+
['stock_item' => $stockItemTable],
182+
'selection.product_id = stock_item.product_id',
183+
[]
178184
)
179185
->where(
180-
'(selection.selection_can_change_qty or selection.selection_qty <= stock.qty) and stock.stock_status'
181-
);
186+
'('
187+
. 'selection.selection_can_change_qty > 0'
188+
. ' or '
189+
. 'selection.selection_qty <= stock.qty'
190+
. ' or '
191+
.'stock_item.manage_stock = 0'
192+
. ')'
193+
)
194+
->where('stock.stock_status = 1');
195+
182196
return $this;
183197
}
184198

app/code/Magento/Bundle/Test/Unit/Model/ResourceModel/Selection/CollectionTest.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,46 @@ protected function setUp()
111111

112112
public function testAddQuantityFilter()
113113
{
114-
$tableName = 'cataloginventory_stock_status';
115-
$this->entity->expects($this->once())
114+
$statusTableName = 'cataloginventory_stock_status';
115+
$itemTableName = 'cataloginventory_stock_item';
116+
$this->entity->expects($this->exactly(2))
116117
->method('getTable')
117-
->willReturn($tableName);
118-
$this->select->expects($this->once())
118+
->willReturnMap([
119+
['cataloginventory_stock_item', $itemTableName],
120+
['cataloginventory_stock_status', $statusTableName],
121+
]);
122+
$this->select->expects($this->exactly(2))
119123
->method('joinInner')
120-
->with(
121-
['stock' => $tableName],
122-
'selection.product_id = stock.product_id',
123-
[]
124+
->withConsecutive(
125+
[
126+
['stock' => $statusTableName],
127+
'selection.product_id = stock.product_id',
128+
[],
129+
],
130+
[
131+
['stock_item' => $itemTableName],
132+
'selection.product_id = stock_item.product_id',
133+
[],
134+
]
124135
)->willReturnSelf();
136+
$this->select
137+
->expects($this->exactly(2))
138+
->method('where')
139+
->withConsecutive(
140+
[
141+
'('
142+
. 'selection.selection_can_change_qty > 0'
143+
. ' or '
144+
. 'selection.selection_qty <= stock.qty'
145+
. ' or '
146+
.'stock_item.manage_stock = 0'
147+
. ')',
148+
],
149+
[
150+
'stock.stock_status = 1',
151+
]
152+
)->willReturnSelf();
153+
125154
$this->assertEquals($this->model, $this->model->addQuantityFilter());
126155
}
127156
}

app/code/Magento/Catalog/etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@
16391639
<column name="product_id"/>
16401640
<column name="store_id"/>
16411641
</constraint>
1642-
<index name="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="btree">
1642+
<index name="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="hash">
16431643
<column name="product_id"/>
16441644
<column name="category_id"/>
16451645
<column name="store_id"/>

app/code/Magento/GiftMessage/etc/db_schema.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
<column name="gift_message_id"/>
2020
</constraint>
2121
</table>
22-
<table name="quote" resource="quote" comment="Sales Flat Quote">
22+
<table name="quote" resource="checkout" comment="Sales Flat Quote">
2323
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"
2424
comment="Gift Message Id"/>
2525
</table>
26-
<table name="quote_address" resource="quote" comment="Sales Flat Quote Address">
26+
<table name="quote_address" resource="checkout" comment="Sales Flat Quote Address">
2727
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"
2828
comment="Gift Message Id"/>
2929
</table>
30-
<table name="quote_item" resource="quote" comment="Sales Flat Quote Item">
30+
<table name="quote_item" resource="checkout" comment="Sales Flat Quote Item">
3131
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"
3232
comment="Gift Message Id"/>
3333
</table>
34-
<table name="quote_address_item" resource="quote" comment="Sales Flat Quote Address Item">
34+
<table name="quote_address_item" resource="checkout" comment="Sales Flat Quote Address Item">
3535
<column xsi:type="int" name="gift_message_id" padding="11" unsigned="false" nullable="true" identity="false"
3636
comment="Gift Message Id"/>
3737
</table>

app/code/Magento/OfflineShipping/etc/db_schema.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
<column xsi:type="smallint" name="free_shipping" padding="5" unsigned="true" nullable="false" identity="false"
4646
default="0" comment="Free Shipping"/>
4747
</table>
48-
<table name="quote_address" resource="quote" comment="Sales Flat Quote Address">
48+
<table name="quote_address" resource="checkout" comment="Sales Flat Quote Address">
4949
<column xsi:type="smallint" name="free_shipping" padding="5" unsigned="true" nullable="false" identity="false"
5050
default="0" comment="Free Shipping"/>
5151
</table>
52-
<table name="quote_item" resource="quote" comment="Sales Flat Quote Item">
52+
<table name="quote_item" resource="checkout" comment="Sales Flat Quote Item">
5353
<column xsi:type="smallint" name="free_shipping" padding="5" unsigned="true" nullable="false" identity="false"
5454
default="0" comment="Free Shipping"/>
5555
</table>
56-
<table name="quote_address_item" resource="quote" comment="Sales Flat Quote Address Item">
56+
<table name="quote_address_item" resource="checkout" comment="Sales Flat Quote Address Item">
5757
<column xsi:type="int" name="free_shipping" padding="10" unsigned="true" nullable="true" identity="false"
5858
comment="Free Shipping"/>
5959
</table>

app/code/Magento/Paypal/etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<column name="txn_id"/>
146146
</constraint>
147147
</table>
148-
<table name="quote_payment" resource="quote" comment="Sales Flat Quote Payment">
148+
<table name="quote_payment" resource="checkout" comment="Sales Flat Quote Payment">
149149
<column xsi:type="varchar" name="paypal_payer_id" nullable="true" length="255" comment="Paypal Payer Id"/>
150150
<column xsi:type="varchar" name="paypal_payer_status" nullable="true" length="255"
151151
comment="Paypal Payer Status"/>

app/code/Magento/Persistent/etc/db_schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<column name="updated_at"/>
3838
</index>
3939
</table>
40-
<table name="quote" resource="quote" comment="Sales Flat Quote">
40+
<table name="quote" resource="checkout" comment="Sales Flat Quote">
4141
<column xsi:type="smallint" name="is_persistent" padding="5" unsigned="true" nullable="true" identity="false"
4242
default="0" comment="Is Quote Persistent"/>
4343
</table>

app/code/Magento/Quote/Model/ResourceModel/Quote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function getReservedOrderId($quote)
180180
public function isOrderIncrementIdUsed($orderIncrementId)
181181
{
182182
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */
183-
$adapter = $this->getConnection();
183+
$adapter = $this->_resources->getConnection('sales');
184184
$bind = [':increment_id' => $orderIncrementId];
185185
/** @var \Magento\Framework\DB\Select $select */
186186
$select = $adapter->select();

app/code/Magento/Quote/etc/db_schema.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
10-
<table name="quote" resource="quote" engine="innodb" comment="Sales Flat Quote">
10+
<table name="quote" resource="checkout" engine="innodb" comment="Sales Flat Quote">
1111
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"
1212
comment="Entity Id"/>
1313
<column xsi:type="smallint" name="store_id" padding="5" unsigned="true" nullable="false" identity="false"
@@ -101,7 +101,7 @@
101101
<column name="store_id"/>
102102
</index>
103103
</table>
104-
<table name="quote_address" resource="quote" engine="innodb" comment="Sales Flat Quote Address">
104+
<table name="quote_address" resource="checkout" engine="innodb" comment="Sales Flat Quote Address">
105105
<column xsi:type="int" name="address_id" padding="10" unsigned="true" nullable="false" identity="true"
106106
comment="Address Id"/>
107107
<column xsi:type="int" name="quote_id" padding="10" unsigned="true" nullable="false" identity="false"
@@ -211,7 +211,7 @@
211211
<column name="quote_id"/>
212212
</index>
213213
</table>
214-
<table name="quote_item" resource="quote" engine="innodb" comment="Sales Flat Quote Item">
214+
<table name="quote_item" resource="checkout" engine="innodb" comment="Sales Flat Quote Item">
215215
<column xsi:type="int" name="item_id" padding="10" unsigned="true" nullable="false" identity="true"
216216
comment="Item Id"/>
217217
<column xsi:type="int" name="quote_id" padding="10" unsigned="true" nullable="false" identity="false"
@@ -311,7 +311,7 @@
311311
<column name="store_id"/>
312312
</index>
313313
</table>
314-
<table name="quote_address_item" resource="quote" engine="innodb" comment="Sales Flat Quote Address Item">
314+
<table name="quote_address_item" resource="checkout" engine="innodb" comment="Sales Flat Quote Address Item">
315315
<column xsi:type="int" name="address_item_id" padding="10" unsigned="true" nullable="false" identity="true"
316316
comment="Address Item Id"/>
317317
<column xsi:type="int" name="parent_item_id" padding="10" unsigned="true" nullable="true" identity="false"
@@ -404,7 +404,7 @@
404404
<column name="quote_item_id"/>
405405
</index>
406406
</table>
407-
<table name="quote_item_option" resource="quote" engine="innodb" comment="Sales Flat Quote Item Option">
407+
<table name="quote_item_option" resource="checkout" engine="innodb" comment="Sales Flat Quote Item Option">
408408
<column xsi:type="int" name="option_id" padding="10" unsigned="true" nullable="false" identity="true"
409409
comment="Option Id"/>
410410
<column xsi:type="int" name="item_id" padding="10" unsigned="true" nullable="false" identity="false"
@@ -422,7 +422,7 @@
422422
<column name="item_id"/>
423423
</index>
424424
</table>
425-
<table name="quote_payment" resource="quote" engine="innodb" comment="Sales Flat Quote Payment">
425+
<table name="quote_payment" resource="checkout" engine="innodb" comment="Sales Flat Quote Payment">
426426
<column xsi:type="int" name="payment_id" padding="10" unsigned="true" nullable="false" identity="true"
427427
comment="Payment Id"/>
428428
<column xsi:type="int" name="quote_id" padding="10" unsigned="true" nullable="false" identity="false"
@@ -458,7 +458,7 @@
458458
<column name="quote_id"/>
459459
</index>
460460
</table>
461-
<table name="quote_shipping_rate" resource="quote" engine="innodb" comment="Sales Flat Quote Shipping Rate">
461+
<table name="quote_shipping_rate" resource="checkout" engine="innodb" comment="Sales Flat Quote Shipping Rate">
462462
<column xsi:type="int" name="rate_id" padding="10" unsigned="true" nullable="false" identity="true"
463463
comment="Rate Id"/>
464464
<column xsi:type="int" name="address_id" padding="10" unsigned="true" nullable="false" identity="false"
@@ -486,7 +486,7 @@
486486
<column name="address_id"/>
487487
</index>
488488
</table>
489-
<table name="quote_id_mask" resource="quote" engine="innodb" comment="Quote ID and masked ID mapping">
489+
<table name="quote_id_mask" resource="checkout" engine="innodb" comment="Quote ID and masked ID mapping">
490490
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true"
491491
comment="Entity Id"/>
492492
<column xsi:type="int" name="quote_id" padding="10" unsigned="true" nullable="false" identity="false"

0 commit comments

Comments
 (0)