No Code Attached Yet
avatar saraheagle
saraheagle
16 Oct 2024

Problem identified

I have a site where the J2Store & Pagination have stopped working together.

If you go to https://www.titusomega.com/antiques-sold/antiques there are 10 pages of results.
-> Search on the left for 'WMF' the search is added to the URL
-> Scroll to the end of the list, you can see there are only 3 pages of results.
-> Now if you click on page 2 the filters are lost from the query string and we are back to the full 10 pages of results.

Proposed solution

The search query string needs to be retained

Open questions

The question is, is this because of the recent pagination changes? It first started happening with them and for a while until the first fix we were experiencing 404 issues. I have updated to ‎4.4.9 this morning and noticed there are changes to the pagination again.

Thanks very much

avatar saraheagle saraheagle - open - 16 Oct 2024
avatar joomla-cms-bot joomla-cms-bot - change - 16 Oct 2024
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Oct 2024
avatar saraheagle saraheagle - change - 16 Oct 2024
The description was changed
avatar saraheagle saraheagle - edited - 16 Oct 2024
avatar fgsw
fgsw - comment - 16 Oct 2024

@saraheagle Can you look at #44257 if its the same Issue?

avatar saraheagle
saraheagle - comment - 16 Oct 2024

Yes, it does look the same issue.
I tested it locally but when I add
'catid' => 'STRING',
as Andrew says works for him, I get the 404 error, like we did a few weeks ago.

I then tested with this old code from an old backup and it works perfectly

protected function _buildDataObject()
{
$data = new \stdClass;

	// Build the additional URL parameters string.
	$params = '';

	if (!empty($this->additionalUrlParams))
	{
		foreach ($this->additionalUrlParams as $key => $value)
		{
			$params .= '&' . $key . '=' . $value;
		}
	}

	$data->all = new PaginationObject(\JText::_('JLIB_HTML_VIEW_ALL'), $this->prefix);

	if (!$this->viewall)
	{
		$data->all->base = '0';
		$data->all->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=');
	}

	// Set the start and previous data objects.
	$data->start    = new PaginationObject(\JText::_('JLIB_HTML_START'), $this->prefix);
	$data->previous = new PaginationObject(\JText::_('JPREV'), $this->prefix);

	if ($this->pagesCurrent > 1)
	{
		$page = ($this->pagesCurrent - 2) * $this->limit;

		if ($this->hideEmptyLimitstart)
		{
			$data->start->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=');
		}
		else
		{
			$data->start->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=0');
		}

		$data->start->base    = '0';
		$data->previous->base = $page;

		if ($page === 0 && $this->hideEmptyLimitstart)
		{
			$data->previous->link = $data->start->link;
		}
		else
		{
			$data->previous->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $page);
		}
	}

	// Set the next and end data objects.
	$data->next = new PaginationObject(\JText::_('JNEXT'), $this->prefix);
	$data->end  = new PaginationObject(\JText::_('JLIB_HTML_END'), $this->prefix);

	if ($this->pagesCurrent < $this->pagesTotal)
	{
		$next = $this->pagesCurrent * $this->limit;
		$end  = ($this->pagesTotal - 1) * $this->limit;

		$data->next->base = $next;
		$data->next->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $next);
		$data->end->base  = $end;
		$data->end->link  = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $end);
	}

	$data->pages = array();
	$stop        = $this->pagesStop;

	for ($i = $this->pagesStart; $i <= $stop; $i++)
	{
		$offset = ($i - 1) * $this->limit;

		$data->pages[$i] = new PaginationObject($i, $this->prefix);

		if ($i != $this->pagesCurrent || $this->viewall)
		{
			$data->pages[$i]->base = $offset;

			if ($offset === 0 && $this->hideEmptyLimitstart)
			{
				$data->pages[$i]->link = $data->start->link;
			}
			else
			{
				$data->pages[$i]->link = \JRoute::_($params . '&' . $this->prefix . 'limitstart=' . $offset);
			}
		}
		else
		{
			$data->pages[$i]->active = true;
		}
	}

	return $data;
}

Add a Comment

Login with GitHub to post a comment