Skip to content

Commit

Permalink
Merge pull request magento#840 from magento-engcom/MSI-824-v2
Browse files Browse the repository at this point in the history
MSI-824: Search in Low Stock Report grid is broken
  • Loading branch information
Valeriy Nayda authored Apr 5, 2018
2 parents a39dae2 + 866e604 commit e9b13e1
Showing 1 changed file with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public function __construct(
$connection,
$resource
);

$this->attributeRepository = $attributeRepository;
$this->stockConfiguration = $stockConfiguration;
$this->getAllowedProductTypesForSourceItems = $getAllowedProductTypesForSourceItems;
Expand All @@ -103,6 +104,10 @@ public function __construct(
protected function _construct()
{
$this->_init(SourceItemModel::class, SourceItemResourceModel::class);

$this->addFilterToMap('source_code', 'main_table.source_code');
$this->addFilterToMap('sku', 'main_table.sku');
$this->addFilterToMap('product_name', 'product_entity_varchar.value');
}

/**
Expand All @@ -117,30 +122,34 @@ public function addStoreFilter(int $storeId)
/**
* @inheritdoc
*/
protected function _beforeLoad()
protected function _renderFilters()
{
parent::_beforeLoad();

$this->addFilterToMap('source_code', 'main_table.source_code');
$this->addFilterToMap('sku', 'main_table.sku');
$this->addFilterToMap('product_name', 'product_entity_varchar.value');

$this->addFieldToSelect('*');
if (false === $this->_isFiltersRendered) {
$this->joinInventoryConfiguration();
$this->joinCatalogProduct();

$this->joinCatalogProduct();
$this->joinInventoryConfiguration();

$this->addProductTypeFilter();
$this->addNotifyStockQtyFilter();
$this->addEnabledSourceFilter();
$this->addSourceItemInStockFilter();

$this->setOrder(SourceItemInterface::QUANTITY, self::SORT_ORDER_ASC);
$this->addProductTypeFilter();
$this->addNotifyStockQtyFilter();
$this->addEnabledSourceFilter();
$this->addSourceItemInStockFilter();
}
return parent::_renderFilters();
}

return $this;
/**
* @inheritdoc
*/
protected function _renderOrders()
{
if (false === $this->_isOrdersRendered) {
$this->setOrder(SourceItemInterface::QUANTITY, self::SORT_ORDER_ASC);
}
return parent::_renderOrders();
}

/**
* joinCatalogProduct depends on dynamic condition 'filterStoreId'
*
* @return void
*/
private function joinCatalogProduct()
Expand Down Expand Up @@ -209,7 +218,7 @@ private function joinInventoryConfiguration()
*/
private function addProductTypeFilter()
{
$this->addFieldToFilter('type_id', $this->getAllowedProductTypesForSourceItems->execute());
$this->addFieldToFilter('product_entity.type_id', $this->getAllowedProductTypesForSourceItems->execute());
}

/**
Expand Down

0 comments on commit e9b13e1

Please sign in to comment.