Jump to content

Backoffice Pagination Error In Products Attribute Section


jacksfregio

Recommended Posts

  • 1 month later...
  • 4 weeks later...

to fix it, you have to override AdminController postProcess function, next to $this->setRedirectAfter: 

public function postProcess()
	{
		try {
			if ($this->ajax) {
				// from ajax-tab.php
				$action = Tools::getValue('action');
				// no need to use displayConf() here
				if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action))) {
					Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
					Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
	
					$return = $this->{'ajaxProcess'.Tools::toCamelCase($action)}();
	
					Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
					Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
	
					return $return;
				} elseif (!empty($action) && $this->controller_name == 'AdminModules' && Tools::getIsset('configure')) {
					$module_obj = Module::getInstanceByName(Tools::getValue('configure'));
					if (Validate::isLoadedObject($module_obj) && method_exists($module_obj, 'ajaxProcess'.$action)) {
						return $module_obj->{'ajaxProcess'.$action}();
					}
				} elseif (method_exists($this, 'ajaxProcess')) {
					return $this->ajaxProcess();
				}
			} else {
				// Process list filtering
				if ($this->filter && $this->action != 'reset_filters') {
					$this->processFilter();
				}
	
				if (isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) {
					//Correction bug du coeur qui ne faisait pas le bon traitement dans le cas de paginations "imbriquées" type attributes_group
					if($this->position_identifier)
					{
						$this->setRedirectAfter(self::$currentIndex.'&'.$this->position_identifier.'='.(int)Tools::getValue('id_attribute_group').'&view'.$this->table.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : ''));
					}
					else{
						$this->setRedirectAfter(self::$currentIndex.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : ''));
					}
				}
	
				// If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
				if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action)))) {
					// Hook before action
					Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
					Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
					// Call process
					$return = $this->{'process'.Tools::toCamelCase($this->action)}();
					// Hook After Action
					Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
					Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
					return $return;
				}
			}
		} catch (PrestaShopException $e) {
			$this->errors[] = $e->getMessage();
		};
		return false;
	}

in the core file you only have : 

if (isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) {
    $this->setRedirectAfter(self::$currentIndex.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : ''));
}
Link to comment
Share on other sites

  • 11 months later...

This is better solution also fix problems on categories:

 if (isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) {
                    $identifier = Tools::getIsset($this->identifier) ? '&'.$this->identifier.'='.(int)Tools::getValue($this->identifier) : '';
                    $this->setRedirectAfter(self::$currentIndex.$identifier.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : ''));
                }
<?php

class AdminController extends AdminControllerCore {

     /**
     * @TODO uses redirectAdmin only if !$this->ajax
     * @return bool
     */
    public function postProcess()
    {
        try {
            if ($this->ajax) {
                // from ajax-tab.php
                $action = Tools::getValue('action');
                // no need to use displayConf() here
                if (!empty($action) && method_exists($this, 'ajaxProcess'.Tools::toCamelCase($action))) {
                    Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));

                    $return = $this->{'ajaxProcess'.Tools::toCamelCase($action)}();

                    Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));

                    return $return;
                } elseif (!empty($action) && $this->controller_name == 'AdminModules' && Tools::getIsset('configure')) {
                    $module_obj = Module::getInstanceByName(Tools::getValue('configure'));
                    if (Validate::isLoadedObject($module_obj) && method_exists($module_obj, 'ajaxProcess'.$action)) {
                        return $module_obj->{'ajaxProcess'.$action}();
                    }
                } elseif (method_exists($this, 'ajaxProcess')) {
                    return $this->ajaxProcess();
                }
            } else {
                // Process list filtering
                if ($this->filter && $this->action != 'reset_filters') {
                    $this->processFilter();
                }

                if (isset($_POST) && count($_POST) && (int)Tools::getValue('submitFilter'.$this->list_id) || Tools::isSubmit('submitReset'.$this->list_id)) {
                    $identifier = Tools::getIsset($this->identifier) ? '&'.$this->identifier.'='.(int)Tools::getValue($this->identifier) : '';
                    $this->setRedirectAfter(self::$currentIndex.$identifier.'&token='.$this->token.(Tools::isSubmit('submitFilter'.$this->list_id) ? '&submitFilter'.$this->list_id.'='.(int)Tools::getValue('submitFilter'.$this->list_id) : ''));
                }

                // If the method named after the action exists, call "before" hooks, then call action method, then call "after" hooks
                if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action)))) {
                    // Hook before action
                    Hook::exec('actionAdmin'.ucfirst($this->action).'Before', array('controller' => $this));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'Before', array('controller' => $this));
                    // Call process
                    $return = $this->{'process'.Tools::toCamelCase($this->action)}();
                    // Hook After Action
                    Hook::exec('actionAdmin'.ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
                    Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => $return));
                    return $return;
                }
            }
        } catch (PrestaShopException $e) {
            $this->errors[] = $e->getMessage();
        };
        return false;
    }
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...