2

Just update to 2.3.0, use setup:di:compile and get following error:

Warning: Declaration of Iksanika\Productmanage\Model\ResourceModel\Search\Collection::_getSelectCountSql($select = NULL, $resetLeftJoins = true) should be compatible with Magento\Catalog\Model\ResourceModel\Product\Collection::_getSelectCountSql(?Magento\Framework\DB\Select $select = NULL, $resetLeftJoins = true) in /home/server/web/server.dev.vendor.com/public_html/app/c
ode/Iksanika/Productmanage/Model/ResourceModel/Search/Collection.php on line 40

    public function _getSelectCountSql($select = null, $resetLeftJoins = true)
{
    $this->_renderFilters();
    $countSelect = is_null($select) ? $this->_getClearSelect() : $this->_buildClearSelect($select);
    if(count($this->getSelect()->getPart(\Zend_Db_Select::GROUP)) > 0)
    {
        $countSelect->reset(\Zend_Db_Select::GROUP);
        $countSelect->distinct(true);
        $group = $this->getSelect()->getPart(\Zend_Db_Select::GROUP);
        $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
    } else {
        $countSelect->columns('COUNT(*)');
    }
    return $countSelect;
}

This error appears only on dev server, on local - all ok. How to resolve this error?

1 Answer 1

2

Add top of your class:


use Magento\Framework\DB\Select;

Now replace following method:


public function _getSelectCountSql(?Select $select = null, $resetLeftJoins = true)
{
    $this->_renderFilters();
    $countSelect = is_null($select) ? $this->_getClearSelect() : $this->_buildClearSelect($select);
    if(count($this->getSelect()->getPart(\Zend_Db_Select::GROUP)) > 0)
    {
        $countSelect->reset(\Zend_Db_Select::GROUP);
        $countSelect->distinct(true);
        $group = $this->getSelect()->getPart(\Zend_Db_Select::GROUP);
        $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
    } else {
        $countSelect->columns('COUNT(*)');
    }
    return $countSelect;
}
1
  • solved. thx, really thx Feb 21, 2019 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.