Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Pagination Tool
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

Hello,

I has one page with a category’s list. I want put the pagination toolbar.

My code is:

protected function _getCategoryCollection()
{
$collection = Mage::getResourceModel(’catalog/category_collection’)
->addAttributeToSelect(’name’)
->addAttributeToSelect(’small_image’)
->addAttributeToSelect(’url_key’)
->addAttributeToSelect(’is_active’)
->addAttributeToFilter(’parent_id’, 66)
->addAttributeToSort(’name’);

$this->_categoryCollection = $collection->load();

return $this->_categoryCollection;
}

protected function _beforeToHtml()
{
$toolbar = $this->getLayout()->createBlock(’comercios/toolbar’, microtime());
$toolbar->setCollection($this->_getCategoryCollection());
$this->setChild(’toolbar’, $toolbar);

$this->_getCategoryCollection()->load();
return parent::_prepareLayout();
}

Are you help me, please?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

This is my complete code, but there is something bad:

class Mage_Comercios_Block_Listado extends Mage_Catalog_Block_Navigation{

protected $_categoryCollection;

public function __construct()
{
parent::__construct();
$this->setTemplate(’comercios/listado.phtml’);
}

/**
* Retrieve loaded category collection
*
* @return Mage_Eav_Model_Entity_Collection_Abstract
*/
public function getLoadedCategoryCollection()
{
return $this->_getCategoryCollection();
}


/** CBC
* Devuelve el listado de establecimientos
*
* @param int $parent
* @param int $maxChildLevel
* @return Varien_Data_Tree_Node_Collection
*/
protected function _getCategoryCollection()
{
$collection = Mage::getResourceModel(’catalog/category_collection’)
->addAttributeToSelect(’name’)
->addAttributeToSelect(’small_image’)
->addAttributeToSelect(’url_key’)
->addAttributeToSelect(’is_active’)
->addAttributeToFilter(’parent_id’, 66)
->addAttributeToSort(’name’);

$this->_categoryCollection = $collection->load();

return $this->_categoryCollection;
}

/**
* Need use as _prepareLayout - but problem in declaring collection from
* another block (was problem with search result)
*/
protected function _beforeToHtml()
{
$toolbar = $this->getLayout()->createBlock(’comercios/toolbar’, microtime());
$toolbar->setCollection($this->_getCategoryCollection());
$this->setChild(’toolbar’, $toolbar);

$this->_getCategoryCollection()->load();
return parent::_prepareLayout();
}

/**
* Retrieve list toolbar HTML
*
* @return string
*/
public function getToolbarHtml()
{
return $this->getChildHtml(’toolbar’);
}

public function setCollection($collection)
{
$this->_categoryCollection = $collection;
return $this;
}

}

 
Magento Community Magento Community
Magento Community
Magento Community
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

In toolbar.php has this code:

class Mage_Comercios_Block_Toolbar extends Mage_Page_Block_Html_Pager
{

public function __construct()
{
parent::__construct();
$this->setTemplate(’comercios/toolbar.phtml’);
}

public function setCollection($collection)
{
parent::setCollection($collection);
return $this;
}

public function getAvailableLimit()
{
return parent::getAvailableLimit();
}

public function getLimit()
{
$limits = $this->getAvailableLimit();
if ($limit = $this->getRequest()->getParam($this->getLimitVarName())) {
if (isset($limits[$limit])) {
return $limit;
}
}
$defaultLimit = Mage::getStoreConfig(’catalog/frontend/product_per_page’);
if ($defaultLimit != ‘’) {
return $defaultLimit;
}
$limits = array_keys($limits);
return $limits[0];
}
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mirasvit
Guru
 
Avatar
Total Posts:  639
Joined:  2009-08-22
 

I think, it is more easy to solve using the extension for work with SEO. Try this Advanced SEO Suite http://mirasvit.com/magento-extensions/advanced-seo-suite.html ,

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top