Skip to content

Commit 346fbfc

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-99228' into 2.3-develop-pr24
2 parents bed9d09 + 1f99b19 commit 346fbfc

File tree

13 files changed

+163
-13
lines changed

13 files changed

+163
-13
lines changed

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,8 @@
483483
<click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/>
484484
<waitForPageLoad stepKey="waitForPageToLoad1"/>
485485
</actionGroup>
486+
<actionGroup name="AdminSetProductDisabled">
487+
<conditionalClick selector="{{AdminProductFormSection.enableProductLabel}}" dependentSelector="{{AdminProductFormSection.productStatusValue('1')}}" visible="true" stepKey="disableProduct"/>
488+
<seeElement selector="{{AdminProductFormSection.productStatusValue('2')}}" stepKey="assertThatProductSetToDisabled"/>
489+
</actionGroup>
486490
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<element name="enableProductAttributeLabel" type="text" selector="//span[text()='Enable Product']/parent::label"/>
2222
<element name="enableProductAttributeLabelWrapper" type="text" selector="//span[text()='Enable Product']/parent::label/parent::div"/>
2323
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
24+
<element name="productStatusValue" type="checkbox" selector="input[name='product[status]'][value='{{value}}']" timeout="30" parameterized="true"/>
2425
<element name="productStatusDisabled" type="checkbox" selector="input[name='product[status]'][disabled]"/>
2526
<element name="enableProductLabel" type="checkbox" selector="input[name='product[status]']+label"/>
2627
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>

app/code/Magento/Checkout/Block/Cart/Totals.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Framework\View\Element\BlockInterface;
1010
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
11+
use Magento\Sales\Model\ConfigInterface;
1112

1213
/**
1314
* Totals cart block.
@@ -45,7 +46,7 @@ class Totals extends \Magento\Checkout\Block\Cart\AbstractCart
4546
* @param \Magento\Framework\View\Element\Template\Context $context
4647
* @param \Magento\Customer\Model\Session $customerSession
4748
* @param \Magento\Checkout\Model\Session $checkoutSession
48-
* @param \Magento\Sales\Model\Config $salesConfig
49+
* @param ConfigInterface $salesConfig
4950
* @param array $layoutProcessors
5051
* @param array $data
5152
* @codeCoverageIgnore
@@ -54,7 +55,7 @@ public function __construct(
5455
\Magento\Framework\View\Element\Template\Context $context,
5556
\Magento\Customer\Model\Session $customerSession,
5657
\Magento\Checkout\Model\Session $checkoutSession,
57-
\Magento\Sales\Model\Config $salesConfig,
58+
ConfigInterface $salesConfig,
5859
array $layoutProcessors = [],
5960
array $data = []
6061
) {

app/code/Magento/Sales/Block/Adminhtml/Order/View.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
namespace Magento\Sales\Block\Adminhtml\Order;
99

10+
use Magento\Sales\Model\ConfigInterface;
11+
1012
/**
1113
* Adminhtml sales order view
1214
* @api
@@ -46,14 +48,14 @@ class View extends \Magento\Backend\Block\Widget\Form\Container
4648
/**
4749
* @param \Magento\Backend\Block\Widget\Context $context
4850
* @param \Magento\Framework\Registry $registry
49-
* @param \Magento\Sales\Model\Config $salesConfig
51+
* @param ConfigInterface $salesConfig
5052
* @param \Magento\Sales\Helper\Reorder $reorderHelper
5153
* @param array $data
5254
*/
5355
public function __construct(
5456
\Magento\Backend\Block\Widget\Context $context,
5557
\Magento\Framework\Registry $registry,
56-
\Magento\Sales\Model\Config $salesConfig,
58+
ConfigInterface $salesConfig,
5759
\Magento\Sales\Helper\Reorder $reorderHelper,
5860
array $data = []
5961
) {
@@ -466,6 +468,8 @@ public function getReviewPaymentUrl($action)
466468
}
467469

468470
/**
471+
* Get edit message
472+
*
469473
* @param \Magento\Sales\Model\Order $order
470474
* @return \Magento\Framework\Phrase
471475
*/
@@ -486,6 +490,8 @@ protected function getEditMessage($order)
486490
}
487491

488492
/**
493+
* Get non editable types
494+
*
489495
* @param \Magento\Sales\Model\Order $order
490496
* @return array
491497
*/

app/code/Magento/Sales/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<preference for="Magento\Sales\Api\RefundOrderInterface" type="Magento\Sales\Model\RefundOrder"/>
117117
<preference for="Magento\Sales\Api\RefundInvoiceInterface" type="Magento\Sales\Model\RefundInvoice"/>
118118
<preference for="Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface" type="Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProvider" />
119+
<preference for="Magento\Sales\Model\ConfigInterface" type="Magento\Sales\Model\Config" />
119120
<type name="Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProvider">
120121
<arguments>
121122
<argument name="providers" xsi:type="array">

app/code/Magento/Tax/Block/Checkout/Discount.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Tax\Block\Checkout;
77

8+
use Magento\Sales\Model\ConfigInterface;
9+
810
/**
911
* Subtotal Total Row Renderer
1012
*/
@@ -19,7 +21,7 @@ class Discount extends \Magento\Checkout\Block\Total\DefaultTotal
1921
* @param \Magento\Framework\View\Element\Template\Context $context
2022
* @param \Magento\Customer\Model\Session $customerSession
2123
* @param \Magento\Checkout\Model\Session $checkoutSession
22-
* @param \Magento\Sales\Model\Config $salesConfig
24+
* @param ConfigInterface $salesConfig
2325
* @param \Magento\Tax\Model\Config $taxConfig
2426
* @param array $layoutProcessors
2527
* @param array $data
@@ -28,7 +30,7 @@ public function __construct(
2830
\Magento\Framework\View\Element\Template\Context $context,
2931
\Magento\Customer\Model\Session $customerSession,
3032
\Magento\Checkout\Model\Session $checkoutSession,
31-
\Magento\Sales\Model\Config $salesConfig,
33+
ConfigInterface $salesConfig,
3234
\Magento\Tax\Model\Config $taxConfig,
3335
array $layoutProcessors = [],
3436
array $data = []
@@ -39,6 +41,8 @@ public function __construct(
3941
}
4042

4143
/**
44+
* Get display including and excluding tax config
45+
*
4246
* @return bool
4347
*/
4448
public function displayBoth()

app/code/Magento/Tax/Block/Checkout/Grandtotal.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Tax\Block\Checkout;
77

8+
use Magento\Sales\Model\ConfigInterface;
9+
810
/**
911
* Subtotal Total Row Renderer
1012
*/
@@ -26,7 +28,7 @@ class Grandtotal extends \Magento\Checkout\Block\Total\DefaultTotal
2628
* @param \Magento\Framework\View\Element\Template\Context $context
2729
* @param \Magento\Customer\Model\Session $customerSession
2830
* @param \Magento\Checkout\Model\Session $checkoutSession
29-
* @param \Magento\Sales\Model\Config $salesConfig
31+
* @param ConfigInterface $salesConfig
3032
* @param \Magento\Tax\Model\Config $taxConfig
3133
* @param array $layoutProcessors
3234
* @param array $data
@@ -35,7 +37,7 @@ public function __construct(
3537
\Magento\Framework\View\Element\Template\Context $context,
3638
\Magento\Customer\Model\Session $customerSession,
3739
\Magento\Checkout\Model\Session $checkoutSession,
38-
\Magento\Sales\Model\Config $salesConfig,
40+
ConfigInterface $salesConfig,
3941
\Magento\Tax\Model\Config $taxConfig,
4042
array $layoutProcessors = [],
4143
array $data = []

app/code/Magento/Tax/Block/Checkout/Shipping.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Tax\Block\Checkout;
77

8+
use Magento\Sales\Model\ConfigInterface;
9+
810
/**
911
* Subtotal Total Row Renderer
1012
*/
@@ -26,7 +28,7 @@ class Shipping extends \Magento\Checkout\Block\Total\DefaultTotal
2628
* @param \Magento\Framework\View\Element\Template\Context $context
2729
* @param \Magento\Customer\Model\Session $customerSession
2830
* @param \Magento\Checkout\Model\Session $checkoutSession
29-
* @param \Magento\Sales\Model\Config $salesConfig
31+
* @param ConfigInterface $salesConfig
3032
* @param \Magento\Tax\Model\Config $taxConfig
3133
* @param array $layoutProcessors
3234
* @param array $data
@@ -35,7 +37,7 @@ public function __construct(
3537
\Magento\Framework\View\Element\Template\Context $context,
3638
\Magento\Customer\Model\Session $customerSession,
3739
\Magento\Checkout\Model\Session $checkoutSession,
38-
\Magento\Sales\Model\Config $salesConfig,
40+
ConfigInterface $salesConfig,
3941
\Magento\Tax\Model\Config $taxConfig,
4042
array $layoutProcessors = [],
4143
array $data = []

app/code/Magento/Tax/Block/Checkout/Subtotal.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Tax\Block\Checkout;
77

8+
use Magento\Sales\Model\ConfigInterface;
9+
810
/**
911
* Subtotal Total Row Renderer
1012
*/
@@ -26,7 +28,7 @@ class Subtotal extends \Magento\Checkout\Block\Total\DefaultTotal
2628
* @param \Magento\Framework\View\Element\Template\Context $context
2729
* @param \Magento\Customer\Model\Session $customerSession
2830
* @param \Magento\Checkout\Model\Session $checkoutSession
29-
* @param \Magento\Sales\Model\Config $salesConfig
31+
* @param ConfigInterface $salesConfig
3032
* @param \Magento\Tax\Model\Config $taxConfig
3133
* @param array $layoutProcessors
3234
* @param array $data
@@ -35,7 +37,7 @@ public function __construct(
3537
\Magento\Framework\View\Element\Template\Context $context,
3638
\Magento\Customer\Model\Session $customerSession,
3739
\Magento\Checkout\Model\Session $checkoutSession,
38-
\Magento\Sales\Model\Config $salesConfig,
40+
ConfigInterface $salesConfig,
3941
\Magento\Tax\Model\Config $taxConfig,
4042
array $layoutProcessors = [],
4143
array $data = []
@@ -46,6 +48,8 @@ public function __construct(
4648
}
4749

4850
/**
51+
* Get display including and excluding tax config
52+
*
4953
* @return bool
5054
*/
5155
public function displayBoth()

app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
namespace Magento\Wishlist\Model\ResourceModel\Item;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
10+
use Magento\CatalogInventory\Model\Stock;
11+
use Magento\Framework\App\ObjectManager;
912
use Magento\Framework\EntityManager\MetadataPool;
13+
use Magento\Sales\Model\ConfigInterface;
1014

1115
/**
1216
* Wishlist item collection
@@ -144,6 +148,16 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
144148
*/
145149
protected $metadataPool;
146150

151+
/**
152+
* @var TableMaintainer
153+
*/
154+
private $tableMaintainer;
155+
156+
/**
157+
* @var ConfigInterface
158+
*/
159+
private $salesConfig;
160+
147161
/**
148162
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
149163
* @param \Psr\Log\LoggerInterface $logger
@@ -163,6 +177,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
163177
* @param \Magento\Wishlist\Model\ResourceModel\Item $resource
164178
* @param \Magento\Framework\App\State $appState
165179
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
180+
* @param TableMaintainer|null $tableMaintainer
181+
* @param ConfigInterface|null $salesConfig
166182
*
167183
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
168184
*/
@@ -184,7 +200,9 @@ public function __construct(
184200
\Magento\Catalog\Model\Entity\AttributeFactory $catalogAttrFactory,
185201
\Magento\Wishlist\Model\ResourceModel\Item $resource,
186202
\Magento\Framework\App\State $appState,
187-
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null
203+
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
204+
TableMaintainer $tableMaintainer = null,
205+
ConfigInterface $salesConfig = null
188206
) {
189207
$this->stockConfiguration = $stockConfiguration;
190208
$this->_adminhtmlSales = $adminhtmlSales;
@@ -199,6 +217,8 @@ public function __construct(
199217
$this->_catalogAttrFactory = $catalogAttrFactory;
200218
$this->_appState = $appState;
201219
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
220+
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
221+
$this->salesConfig = $salesConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class);
202222
}
203223

204224
/**
@@ -330,6 +350,53 @@ protected function _assignProducts()
330350
return $this;
331351
}
332352

353+
/**
354+
* @inheritdoc
355+
*/
356+
protected function _renderFiltersBefore()
357+
{
358+
parent::_renderFiltersBefore();
359+
360+
$mainTableName = 'main_table';
361+
$connection = $this->getConnection();
362+
363+
if ($this->_productInStock && !$this->stockConfiguration->isShowOutOfStock()) {
364+
$inStockConditions = [
365+
"stockItem.product_id = {$mainTableName}.product_id",
366+
$connection->quoteInto('stockItem.stock_status = ?', Stock::STOCK_IN_STOCK),
367+
];
368+
$this->getSelect()->join(
369+
['stockItem' => $this->getTable('cataloginventory_stock_status')],
370+
join(' AND ', $inStockConditions),
371+
[]
372+
);
373+
}
374+
375+
if ($this->_productVisible) {
376+
$rootCategoryId = $this->_storeManager->getStore()->getRootCategoryId();
377+
$visibleInSiteIds = $this->_productVisibility->getVisibleInSiteIds();
378+
$visibilityConditions = [
379+
"cat_index.product_id = {$mainTableName}.product_id",
380+
$connection->quoteInto('cat_index.category_id = ?', $rootCategoryId),
381+
$connection->quoteInto('cat_index.visibility IN (?)', $visibleInSiteIds)
382+
];
383+
$this->getSelect()->join(
384+
['cat_index' => $this->tableMaintainer->getMainTable($this->_storeManager->getStore()->getId())],
385+
join(' AND ', $visibilityConditions),
386+
[]
387+
);
388+
}
389+
390+
if ($this->_productSalable) {
391+
$availableProductTypes = $this->salesConfig->getAvailableProductTypes();
392+
$this->getSelect()->join(
393+
['cat_prod' => $this->getTable('catalog_product_entity')],
394+
$this->getConnection()->quoteInto('cat_prod.type_id IN (?)', $availableProductTypes),
395+
[]
396+
);
397+
}
398+
}
399+
333400
/**
334401
* Add filter by wishlist object
335402
*

0 commit comments

Comments
 (0)