/** * Add JOIN to warehouse data to calculate qty. * * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $subject * @param \Closure $proceed * @return \Magento\Framework\DB\Select */ public function aroundGetSelectCountSql(\Magento\Catalog\Model\ResourceModel\Product\Collection $subject, \Closure $proceed) { /** @var \Magento\Framework\DB\Select $result */ $result = $proceed(); $this->_queryModGrid->modifySelect($result); return $result; }
/** * Replace WHERE-filtering by HAVING-filtering. * * @param \Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection $subject * @param \Closure $proceed * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection * @param $field * @param null $condition */ public function aroundAddFilter(\Magento\CatalogInventory\Ui\DataProvider\Product\AddQuantityFilterToCollection $subject, \Closure $proceed, \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, $field, $condition = null) { /* skip identical conditions () */ $regKey = print_r($condition, true); if (!isset($this->_regCond[$regKey])) { $conn = $collection->getConnection(); $select = $collection->getSelect(); $equation = $this->_repoModifierProductGFrid->getEquationQty(); $prepared = $conn->prepareSqlCondition($equation, $condition); $select->having($prepared); $this->_regCond[$regKey] = true; } return; }
/** * @param Subject $subject * @param \Closure $proceed * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection * @param $field * @param null $alias * @throws \Magento\Framework\Exception\LocalizedException */ public function aroundAddField(Subject $subject, \Closure $proceed, \Magento\Catalog\Model\ResourceModel\Product\Collection $collection) { $select = $collection->getSelect(); $this->_queryModGrid->modifySelect($select); return; }