0

vendor/magento/framework/Search/Dynamic/Algorithm.php

/**
 * Set lower and upper limit for algorithm
 *
 * @param null|float $lowerLimit
 * @param null|float $upperLimit
 * @return \Magento\Framework\Search\Dynamic\Algorithm
 */
public function setLimits($lowerLimit = null, $upperLimit = null)
{
    $this->_lowerLimit = empty($lowerLimit) ? null : (double)$lowerLimit;
    $this->_upperLimit = empty($upperLimit) ? null : (double)$upperLimit;

    return $this;
}

once $lowerLimit is 0 ,the $this->_lowerLimit will be null,

but in our platform $lowerLimit really can be float 0, the it will cause a bug "canot be null " $lower canot be null

vendor/magento/module-elasticsearch/Elasticsearch5/SearchAdapter/Aggregation/Interval.php

/**
 * @inheritdoc
 */
public function loadPrevious($data, $index, $lower = null)
{
    if ($lower) {
        $from = ['gte' => $lower - self::DELTA];
    }
    if ($data) {
        $to = ['lt' => $data - self::DELTA];
    }

    $requestQuery = $this->prepareBaseRequestQuery($from, $to);
    $requestQuery = array_merge_recursive(
        $requestQuery,
        ['size' => 0]
    );

    $queryResult = $this->connectionManager->getConnection()
        ->query($requestQuery);

    $offset = $queryResult['hits']['total'];
    if (!$offset) {
        return false;
    }

    if (is_array($offset)) {
        $offset = $offset['value'];
    }

    return $this->load($index - $offset + 1, $offset - 1, $lower);
}

so tell me why is it?

1
  • the reason $lowerLimit is 0 is that we enabled the show out of stock feature. our goods will still show in frontpage where they are out of stock. – Xie Lei Oct 14 '20 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.