0

We bought this job application suite module from a dev that I can't get in touch with and our store managers can't view applications past the first page (set of 20). If they try to go to the second page of applications (admin side) they get an ajax spinner that loads in the panel and then the entire admin reloads inside that panel but the spinner never stops. They get the same thing if they try to change the results per page.

I had to do quite a bit of work on the code to get it to work in the first place, but I can't find the hook where pagination of the grid is called to mess with it.

I need to get this working ASAP. Here is the code from the class that loads the tab that shows applicants for the job listing:

class ModuleMart_Jobs_Block_Adminhtml_Job_Edit_Tab_Applicants extends Mage_Adminhtml_Block_Widget_Grid
{

    public function __construct()
    {   
        parent::__construct();
        $this->setId('applicants_grid');
        $this->setDefaultSort('id');
        $this->setUseAjax(true);

    }

    protected function _beforeToHtml()
    {
        $this->setId($this->getId().'_'.$this->getIndex());
        $this->getChild('reset_filter_button')->setData('onclick', $this->getJsObjectName().'.resetFilter()');
        $this->getChild('search_button')->setData('onclick', $this->getJsObjectName().'.doFilter()');
        return parent::_beforeToHtml();
    }

    protected function _prepareCollection()
    {
        $id = $this->getRequest()->getParam('id');
        $collection = Mage::getModel('jobs/applications')->getCollection()->addFilter('job_id', $id);

        $resource = Mage::getSingleton('core/resource');

        $this->setCollection($collection);

        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {

        $this->addColumn('applicant_name', array(
            'header'    => Mage::helper('jobs')->__('Applicant Name'),
            'sortable'  => true,
            'index'     => 'applicant_name'
        ));  

        $this->addColumn('applicant_email', array(
            'header'    => Mage::helper('jobs')->__('Applicant Email'),
            'sortable'  => true,
            'index'     => 'applicant_email',
        ));

        $this->addColumn('created_at', array(
            'header'    => Mage::helper('jobs')->__('Applied Date'),
            'sortable'  => true,
            'index'     => 'created_at',
        ));
        $this->addColumn('action',
            array(
                'header'=>  Mage::helper('jobs')->__('Download Resume'),
                'width' => '100',
                'type'  => 'action',
                'getter'=> 'getId',
                'actions'   => array(
                    array(
                        'caption'   => Mage::helper('jobs')->__('Download'),
                        'url'   => array('base'=> 'adminhtml/jobs_applications/view/'),
                        'field' => 'id'
                    )
                ),
                'filter'=> false,
                'is_system' => true,
                'sortable'  => false,
        ));

        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('adminhtml/jobs_applications/view/', array('id' => $row->getId()));
    }   

    public function getGridUrl()
    {  
        return $this->getUrl('adminhtml/jobs_applications/view/',    array('index' => $this->getIndex(),'_current'=>true));
    }

    protected function _getStore()
    {
        return Mage::app()->getStore($this->getRequest()->getParam('store'));
    }    
}   

Hopefully this is just some small tweak that I am nmissing, but any help would be greatly appreciated. I need to get the pager working, or just not load the pager (display all rows on the first page) since there should never be more than 100 applicants per job listing.

Please let me know if there is anything else I should be looking for.

EDIT

I changed $this->setUseAjax to false which obviously fixed the spinner issue, but now it loads up a different block and reports that "application no longer exists" when I haven't made a selection.

Here is the model that Melvyn mentioned:

class ModuleMart_Jobs_Model_Applications extends Mage_Core_Model_Abstract{
    /**
     * Entity code.
     * Can be used as part of method name for entity processing
     */
    const ENTITY= 'jobs_applications';
    const CACHE_TAG = 'jobs_applications';
    /**
     * Prefix of model events names
     * @var string
     */
    protected $_eventPrefix = 'jobs_applications';

    /**
     * Parameter name in event
     * @var string
     */
    protected $_eventObject = 'applications';
    protected $_productInstance = null;
    /**
     * constructor
     * @access public
     */
    public function _construct(){
        parent::_construct();
        $this->_init('jobs/applications');
    }
    /**
     * before save job
     * @access protected
     */
    protected function _beforeSave(){
        parent::_beforeSave();
        $now = Mage::getSingleton('core/date')->gmtDate();
        if ($this->isObjectNew()){
            $this->setCreatedAt($now);
        }
        $this->setUpdatedAt($now);
        return $this;
    }
    /**
     * check URL key
     * @access public
     */
    public function checkUrlKey($urlKey, $active = true){
        return $this->_getResource()->checkUrlKey($urlKey, $active);
    }
}
  • Does this work when you remove the third party module? – brentwpeterson Oct 29 '15 at 18:27
  • This isn't where the offending code is. It's in Modulemart/Jobs/Model/Applications.php. And whatever getCollection() in that file is doing. – Melvyn Oct 29 '15 at 18:39
  • @brentwpeterson the only thing not working is the small admin tab of the third party module. – mtrueblood Oct 29 '15 at 18:41
  • @Melvyn, I added the code from that model to my question above – mtrueblood Oct 29 '15 at 18:45
0

Try by comment out function _beforeToHtml() as class

Mage_Adminhtml_Block_Widget_Grid

will do it

/*
protected function _beforeToHtml()
{
    $this->setId($this->getId().'_'.$this->getIndex());
    $this->getChild('reset_filter_button')->setData('onclick', $this->getJsObjectName().'.resetFilter()');
    $this->getChild('search_button')->setData('onclick', $this->getJsObjectName().'.doFilter()');
    return parent::_beforeToHtml();
}
*/ 
  • I commented out that code but still get the same issue. Did you mean that I should also not extend Mage_Adminhtml_Block_Widget_Grid? – mtrueblood Oct 29 '15 at 18:49
  • No.check GridUrl as per $this->getGridUrl() is present in controller file – Minesh Patel Oct 29 '15 at 18:55
  • the problem is both $this->getGridUrl() and $this->getRowUrl() pointing to same URL – Minesh Patel Oct 29 '15 at 19:04
  • check class for example Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Related and Mage_Adminhtml_Catalog_ProductController and catalog layout file and follow them – Minesh Patel Oct 29 '15 at 19:09
  • return $this->getUrl('*/*/view', array('id' => $row->getId())); return $this->getUrl('*/*/grid', array('index' => $this->getIndex(),'_current'=>true)); Is this the right method? also do I need to create a grid and view for these to work? It looks like the dev was trying to borrow from another block here right? – mtrueblood Oct 29 '15 at 19:44

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.