2
私はgetResultCountにアクセスしようとしているを含むときに、現在の検索ページの結果数を取得する()\でMagentoの\ CatalogSearch \ブロック\結果。不明なエラー:私は、私は、次のエラーが表示さ<?=$block->getSearchResults();?>
Magentoの2 - 私は、次のブロックが作成した</p> <p>ブロック
を呼び出すと
class GetSearch extends \Magento\Framework\View\Element\Template
{
protected $_pageTitle;
protected $_result;
public function __construct(\Magento\Framework\View\Element\Template\Context $context,\Magento\Framework\View\Page\Title $pageTitle,
\Magento\CatalogSearch\Block\Result $result)
{
$this->_pageTitle = $pageTitle;
$this->_result = $result;
parent::__construct($context);
}
public function getTitle()
{
return $this->_pageTitle->getShort();
}
public function getSearchResults()
{
return $this->_result->getResultCount();
}
}
ブール
上メンバ関数getLoadedProductCollection(への呼び出しを)私はこのことについて間違った道を進んでいると思うと、何とか検索結果を含む現在のオブジェクトにアクセスする必要がありますが、私は少し失われています。
これを行う最善の方法は何ですか?