php - PrestaShop 1.6 后台分页无法正常工作

标签 php prestashop payment prestashop-1.6

您好,我正在开发 PrestaShop paymnet 模块。我希望列出所有事务并使用 Helper List 类进行,我设置了分页选项,但分页无法正常工作。底部显示分页,如 1..2..4 页,但列出所有交易。这是渲染助手列表方法的部分代码。

$helper = new HelperList();

$helper->show_toolbar = false;
$helper->no_link = true; 
$helper->_pagination = array(10, 20, 50, 100, 200);

$content = $this->getCancelRows();
$helper->listTotal = count($this->getCancelRows());

return $helper->generateList($content, $this->fields_list);

感谢大家的帮助!如果我提出重复的问题,我很抱歉,但我的研究以失败告终。干杯!

最佳答案

我找到了解决这个问题的方法。只需添加对结果进行分页的功能。如果有人有类似的问题。下面我粘贴了工作代码。

public function initList() {

    $content = $this->getCancelRows();
    $helper->listTotal = count( $this->getCancelRows() );

    /* Paginate the result */
    $page = ( $page = Tools::getValue( 'submitFilter' . $helper->table ) ) ? $page : 1;
    $pagination = ( $pagination = Tools::getValue( $helper->table . '_pagination' ) ) ? $pagination : 10;
    $content = $this->paginate_content( $content, $page, $pagination );

    return $helper->generateList( $content, $this->fields_list );

}

public function paginate_content( $content, $page = 1, $pagination = 10 ) {

   if( count($content) > $pagination ) {
        $content = array_slice( $content, $pagination * ($page - 1), $pagination );
   }

   return $content;

}

关于php - PrestaShop 1.6 后台分页无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42268924/

相关文章:

web-services - 通过API仅更新PrestaShop产品的指定字段

Paypal Simple Adaptive Payment - 经典代码有什么问题

desktop - 桌面应用程序的信用卡支付解决方案

php - 使用 php 与 mysql 嵌套选择查询混淆

PHP/MySQL OnClick 更新 MySQL

php - Redis,自动保存在磁盘上

html - 适用于Prestashop的自适应视频Youtube

php - 在 prestashop 中为 CMS 页面创建新模板

android - 如何在手机中使用 NFC 阅读器接收付款

php - 如果来自数据库的散列密码与输入密码匹配,则登录