如何在magento 2中打印集合mysql查询?
还有getSelect()->__toString();就是在Magento 1可用于收集打印查询。像下面的例子 $products = Mage::getModel(‘catalog/product’) ->addAttributeToFilter(‘status’, array(‘eq’ => 1)); echo $products->getSelect()->__toString(); magento 2中有什么可用的方法吗?我找到了这个,->printLogQuery(true);但是对我不起作用。 更新:下面是代码。我正在尝试获得畅销产品。它的工作完美,但我想打印查询进行调试。 $this->_collection->getSelect() ->joinLeft( 'sales_order_item', 'e.entity_id = sales_order_item.product_id', array('qty_ordered'=>'SUM(sales_order_item.qty_ordered)')) ->group('e.entity_id') ->order('qty_ordered '.$this->getCurrentDirectionReverse());