Skip to content

Commit 5618bf8

Browse files
authored
Merge pull request #4725 from magento-chaika/Chaika-PR-2019-09-03-2.2
Chaika-PR-2019-09-03-2.2
2 parents e1211b6 + 8dd332d commit 5618bf8

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ public function getReviewPaymentUrl($action)
466466
}
467467

468468
/**
469+
* Get edit message
470+
*
469471
* @param \Magento\Sales\Model\Order $order
470472
* @return \Magento\Framework\Phrase
471473
*/
@@ -486,6 +488,8 @@ protected function getEditMessage($order)
486488
}
487489

488490
/**
491+
* Get non editable types
492+
*
489493
* @param \Magento\Sales\Model\Order $order
490494
* @return array
491495
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function __construct(
3939
}
4040

4141
/**
42+
* Get display including and excluding tax config
43+
*
4244
* @return bool
4345
*/
4446
public function displayBoth()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function __construct(
4646
}
4747

4848
/**
49+
* Get display including and excluding tax config
50+
*
4951
* @return bool
5052
*/
5153
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\Config;
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 Config
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 Config|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+
Config $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(Config::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)