Guest User

Untitled

a guest
Dec 12th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <reference name="product_list_toolbar">
  2. <action method="addPagerLimit"><limit>20</limit></action>
  3. <!--action method="setDefaultGridPerPage"><limit>20</limit></action-->
  4. <!--action method="setDefaultListPerPage"><limit>20</limit></action-->
  5. </reference>
  6.  
  7. <layout>
  8. <CATEGORY_13>
  9. <reference name="product_list_toolbar">
  10. <action method="addPagerLimit"><mode>grid</mode><limit>15</limit></action>
  11. <action method="addPagerLimit"><mode>list</mode><limit>15</limit></action>
  12. </reference>
  13. </CATEGORY_13>
  14. <CATEGORY_7>
  15. <reference name="product_list_toolbar">
  16. <action method="addPagerLimit"><mode>grid</mode><limit>30</limit></action>
  17. <action method="addPagerLimit"><mode>list</mode><limit>30</limit></action>
  18. </reference>
  19. </CATEGORY_7>
  20. </layout>
  21.  
  22. <?php
  23. class Namepace_Modulename_Model_Observer {
  24.  
  25. /**
  26. *
  27. * Holds Categoy ids
  28. *
  29. * @var array
  30. *
  31. */
  32. protected $_categoryIds = array(13,7) ;
  33.  
  34. /**
  35. *
  36. * Holds page Sizes
  37. *
  38. * @var array
  39. *
  40. */
  41. protected $_pageSize = array(
  42. 13 => 15
  43. 7 => 30
  44. ) ;
  45.  
  46. /**
  47. *
  48. * Use to set Page Size
  49. *
  50. * @param Varint Object | $observer
  51. *
  52. *
  53. */
  54. public function setPageSizeForCategory($observer)
  55. {
  56. $controller = $observer->getAction();
  57. $fullActionName = $controller->getFullActionName();
  58. $id = (int)$controller->getRequest()->getParam('id');
  59.  
  60. //check whether current page is correspond to our special category. If not, returns
  61. if ($fullActionName == "catalog_category_view" && $id == in_array($this->_categoryIds)) {
  62.  
  63. //check whether toolbar block exist or not
  64. $toolbar = $controller->getLayout()->getBlock('product_list_toolbar');
  65. if($toolbar) {
  66.  
  67. //sets page size to corresponding mode
  68. $listMode = $toolbar->getCurrentMode();
  69. $toolbar = $toolbar->addPagerLimit($listMode , $this->_pageSize[$id]);
  70. }
  71.  
  72. }
  73. return;
  74. }
  75. }
Add Comment
Please, Sign In to add comment