Skip to content

Commit 90c68da

Browse files
authored
Merge pull request #60 from mmenozzi/category-api-pagination-fix
IMPORTANT: fixes pagination of category API
2 parents 0205ffb + 887ef20 commit 90c68da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

code/controllers/ApiController.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function categoryAction()
126126
->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
127127
->setOrder('entity_id', Varien_Db_Select::SQL_ASC)
128128
->setPageSize($limit)
129-
->setCurPage($page + 1);
129+
->setCurPage($page);
130130

131131
$items = [];
132132

@@ -144,9 +144,9 @@ public function categoryAction()
144144
$items[] = $data;
145145
}
146146

147-
$this->getResponse()->setHeader('Total-Page-Count', $categories->getLastPageNumber() - 1);
147+
$this->getResponse()->setHeader('Total-Page-Count', $categories->getLastPageNumber());
148148

149-
if ($page > $categories->getLastPageNumber() - 1) {
149+
if ($page > $categories->getLastPageNumber()) {
150150
$this->getResponse()->setBody(json_encode([]));
151151
} else {
152152
$this->getResponse()->setBody(json_encode($items));
@@ -219,7 +219,7 @@ private function getIntParam($key, $errmsg = null)
219219
private function setStore()
220220
{
221221
$storeid = $this->getRequest()->getParam('store');
222-
222+
223223
if (isset($storeid) && is_numeric($storeid)) {
224224
try {
225225
Mage::app()->getStore((int) $storeid);

0 commit comments

Comments
 (0)