Instantly share code, notes, and snippets.

Embed
What would you like to do?
Workaround when filters don't appear anymore on left column with the elasticsearch module for Magento.
<?php
// app/code/community/JR/Search/Model/Resource/Catalog/Product/Collection.php
// Making an override would be better!
protected function _getParams()
{
$store = Mage::app()->getStore($this->getStoreId());
$params = array();
$params['locale_code'] = $store->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE);
$params['filters'] = $this->_searchQueryFilters;
$params['range_filters'] = $this->_searchQueryRangeFilters;
if (!empty($this->_sortBy)) {
$params['sort_by'] = $this->_sortBy;
}
if (Mage::app()->getRequest()->getQuery('limit')) {
$this->_pageSize = Mage::app()->getRequest()->getQuery('limit');
} else if (Mage::getSingleton('catalog/session')->getLimitPage()) {
$this->_pageSize = Mage::getSingleton('catalog/session')->getLimitPage();
} else {
$block = Mage::app()->getLayout()->createBlock('catalog/product_list_toolbar');
$this->_pageSize = $block->getDefaultPerPageValue();
}
if (Mage::app()->getRequest()->getQuery('p')) {
$this->_curPage = Mage::app()->getRequest()->getQuery('p');
}
if ($this->_pageSize !== false) {
$page = ($this->_curPage > 0) ? (int) $this->_curPage : 1;
$rowCount = ($this->_pageSize > 0) ? (int) $this->_pageSize : 1;
$params['offset'] = $rowCount * ($page - 1);
$params['limit'] = $rowCount;
}
if (!empty($this->_facetsConditions)) {
$params['facets'] = $this->_facetsConditions;
}
return $params;
}
<?php
// app/design/frontend/<package>/<theme>/template/catalog/layer/view.phtml
// Add this on top
$this->getLayer()->getProductCollection()->load();
// Rest of code...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment