Items_per_page session at pagination

Hello everyone,

I have already added pagination inside product edit page in admin panel of cs-cart version 4.18.x. Everything is working fine (items per page, 10-20-50 and so on). My goal is to keep those choices I have made to all my products… For example, I chose to display 50 items per page but If I navigate to another product the pagination is 10 items per page… How could I add this values to sessions, according to cs-cart?

I tried some code but could not get it done… for example I have sothing like this:

$params = $_REQUEST;
    if (!empty($_REQUEST['items_per_page'])) {
        Registry::set('session.item_per_page', $_REQUEST['items_per_page']);
    }

$params['page'] = (empty($_REQUEST['page'])) ? 1 : $_REQUEST['page'];
$params['items_per_page'] = !empty(Registry::get('session.item_per_page')) ? Registry::get('session.item_per_page') : 10;
$offset = ($params['page'] - 1) * $params['items_per_page'];

I do not know if makes any sense, but looking for a hint… Am I setting up correctly the session variable? Am I missing something?

thanks in advance

Please try to use

Tygh::$app['session']['item_per_page']

instead of the Registry class

2 Likes

Hello thanks for the answer. Seems to be working!!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.