Skip to content

Instantly share code, notes, and snippets.

@jreinke
Last active December 16, 2015 02:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jreinke/5364062 to your computer and use it in GitHub Desktop.
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