I can't find the what query rendes here and i can't it is not readable so any can to find what query renders hear please tell what are the table involved here

 public function getCount(\Magento\Catalog\Model\Layer\Filter\FilterInterface $filter)
        // clone select from collection with filters
        $select = clone $filter->getLayer()->getProductCollection()->getSelect();
        // reset columns, order and limitation conditions

        $connection = $this->getConnection();
        $attribute = $filter->getAttributeModel();
        $tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
        $conditions = [
            "{$tableAlias}.entity_id = e.entity_id",
            $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()),
            $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()),

            [$tableAlias => $this->getMainTable()],
            join(' AND ', $conditions),
            ['value', 'count' => new \Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")]

        return $connection->fetchPairs($select);
  • Dont worry this is not array when echo this before return. Commented Jun 22, 2020 at 11:11

2 Answers 2


Before return you can print this and check which table you want.

  echo $select->__toString();
  • How can print if it is array?
    – Sabareesh
    Commented Jun 22, 2020 at 11:08
  • echo used and die; Commented Jun 22, 2020 at 11:09
  • It is not working bro if i put die also it is coming
    – Sabareesh
    Commented Jun 22, 2020 at 11:13
  • If die is not working here so please check its overide. Commented Jun 22, 2020 at 11:14
  • No it is not overrided it is a model file it is only in vendor/*
    – Sabareesh
    Commented Jun 22, 2020 at 11:28

instead of dying, you can log the query:

you may use these 3 lines:

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/querytounderstand.log');
$logger = new \Zend\Log\Logger();
$logger->info($select->__toString()); // as per Jijay suggestion

Add a log in Magento is talke about here: Magento 2: Replacement for Mage::log method?

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.