Skip to content

Commit

Permalink
Fixes Smile-SA#1591 Smile-SA#1581 Explicit collection page size
Browse files Browse the repository at this point in the history
when only fetching aggregations.
Keeps the "Show all" working by distinguishing between NO page size set ("Show all") and a page size of 0.
Also covers someone setting a page size of null for the fun.
  • Loading branch information
rbayet committed Oct 31, 2019
1 parent bab19c1 commit f20924a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ private function initLayer()

$this->applyFilters();

$this->layerResolver->get()->getProductCollection()->setPageSize(0);

return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ public function resetOrder()
return $this;
}

/**
* {@inheritDoc}
*/
public function setPageSize($size)
{
/*
* Explicitely setting the page size to false or null is to be treated as having not set any page size.
* That is: no pagination, all items are expected.
*/
$size = ($size === null) ? false : $size;
$this->_pageSize = $size;

return $this;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -532,7 +547,7 @@ private function prepareRequest()
$searchRequestName = $this->searchRequestName;

// Pagination params.
$size = $this->_pageSize ? $this->_pageSize : $this->getSize();
$size = ($this->_pageSize !== false) ? $this->_pageSize : $this->getSize();
$from = $size * (max(1, $this->_curPage) - 1);

// Setup sort orders.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function getAttributes($category)
/** @var \Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection $fulltextCollection */
$fulltextCollection = $this->fulltextCollectionFactory->create();
$fulltextCollection->setStoreId($storeId)
->setPageSize(1)
->setPageSize(0)
->addFieldToFilter('category_ids', $this->getCategoryFilterParam($category));

$attributeSetIds = array_keys($fulltextCollection->getFacetedData('attribute_set_id'));
Expand Down

0 comments on commit f20924a

Please sign in to comment.