Smile-SA / smile-magento-elasticsearch

Magento ElasticSearch Implementation
151 stars 90 forks source link

Returns 0 result if page size is false in collection #154

Closed kirkmadera closed 5 years ago

kirkmadera commented 5 years ago

The protected variable $_pageSize of a Magento collection defaults to false. There is a note above this in \Magento\Framework\Data\Collection that reads "if page size is false, then we works with all items".

/**
 * Pager page size
 *
 * if page size is false, then we works with all items
 *
 * @var int|false
 */
protected $_pageSize = false;

The smile class \Smile\ElasticsuiteCore\Search\Request\Builder::create does not work with pageSize = false appropriately in my opinion. (I just debugged for two days to find this).

If $size is false, it should behave more like Magento intended and return all results.

"All" results is sort of relative because ElasticSearch forces a limit and has a default limit of 10,000 for index.max_result_window (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html). This seems like a reasonable max for returning "all" records in Magento.

\Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection::prepareRequest also has a line of code that does not explicitly consider $size as false which would need to be addressed.

I have a fix for this and will submit it shortly.

kirkmadera commented 5 years ago

Intended to open for M2 module. Closing. See See https://github.com/Smile-SA/elasticsuite/issues/1428