{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/447","labels_url":"https://api.github.com/repos/magento/magento2/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/447/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/447/events","html_url":"https://github.com/magento/magento2/issues/447","id":24705028,"number":447,"title":"Varien_Data_Collection does not support Pagination","user":{"login":"tkdb","id":5831065,"avatar_url":"https://avatars.githubusercontent.com/u/5831065?v=3","gravatar_id":"","url":"https://api.github.com/users/tkdb","html_url":"https://github.com/tkdb","followers_url":"https://api.github.com/users/tkdb/followers","following_url":"https://api.github.com/users/tkdb/following{/other_user}","gists_url":"https://api.github.com/users/tkdb/gists{/gist_id}","starred_url":"https://api.github.com/users/tkdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkdb/subscriptions","organizations_url":"https://api.github.com/users/tkdb/orgs","repos_url":"https://api.github.com/users/tkdb/repos","events_url":"https://api.github.com/users/tkdb/events{/privacy}","received_events_url":"https://api.github.com/users/tkdb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2013-12-23T12:52:36Z","updated_at":"2015-10-05T13:55:25Z","closed_at":"2014-01-03T15:41:08Z","body":"The class `Varien_Data_Collection` implements pagination methods like `setPageSize` and `setCurPage` but the implementation of IteratorAggregate does not reflect when pagination has been enabled. It always returns an ArrayIterator over all items, not reflecting the pagination (no provider for pagination).\r\n\r\nSee as well: http://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working\r\n\r\nThis (https://gist.github.com/tkdb/de651ce0dbc4a2682b39) is untested if extending classes expect getIterator to not do so, which might be a reason why this non-abstract base-class contains such non-working boilerplate pagination code.\r\n\r\nReproduced with code of 1.5.0.x (the other bug-tracker seems broken, I'm unable to report), the code/problem remains the same in master:\r\n\r\nhttps://github.com/magento/magento2/blob/master/lib/Magento/Data/Collection.php#L772\r\n"},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/145534464","html_url":"https://github.com/magento/magento2/issues/447#issuecomment-145534464","issue_url":"https://api.github.com/repos/magento/magento2/issues/447","id":145534464,"user":{"login":"ahofstetter","id":1895030,"avatar_url":"https://avatars.githubusercontent.com/u/1895030?v=3","gravatar_id":"","url":"https://api.github.com/users/ahofstetter","html_url":"https://github.com/ahofstetter","followers_url":"https://api.github.com/users/ahofstetter/followers","following_url":"https://api.github.com/users/ahofstetter/following{/other_user}","gists_url":"https://api.github.com/users/ahofstetter/gists{/gist_id}","starred_url":"https://api.github.com/users/ahofstetter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahofstetter/subscriptions","organizations_url":"https://api.github.com/users/ahofstetter/orgs","repos_url":"https://api.github.com/users/ahofstetter/repos","events_url":"https://api.github.com/users/ahofstetter/events{/privacy}","received_events_url":"https://api.github.com/users/ahofstetter/received_events","type":"User","site_admin":false},"created_at":"2015-10-05T13:55:25Z","updated_at":"2015-10-05T13:55:25Z","body":"class Pageable_Varien_Data_Collection extends Varien_Data_Collection\r\n{\r\n    /**\r\n     * Load data\r\n     *\r\n     * @param   bool $printQuery\r\n     * @param   bool $logQuery\r\n     *\r\n     * @return  Pageable_Varien_Data_Collection\r\n     */\r\n    public function load($printQuery = false, $logQuery = false)\r\n    {\r\n        if ($this->isLoaded()) {\r\n            return $this;\r\n        }\r\n        $this->_renderLimit();\r\n        $this->_setIsLoaded();\r\n        return $this;\r\n    }\r\n    /**\r\n     * @return  Pageable_Varien_Data_Collection\r\n     */\r\n    protected function _renderLimit()\r\n    {\r\n        if ($this->_pageSize) {\r\n            $currentPage = $this->getCurPage();\r\n            $pageSize = $this->_pageSize;\r\n            $firstItem = (($currentPage - 1) * $pageSize + 1);\r\n            $lastItem = $firstItem + $pageSize;\r\n            $iterator = 1;\r\n            foreach ($this->getItems() as $key => $item) {\r\n                $pos = $iterator;\r\n                $iterator++;\r\n                if ($pos >= $firstItem && $pos <= $lastItem) {\r\n                    continue;\r\n                }\r\n                $this->removeItemByKey($key);\r\n            }\r\n        }\r\n        return $this;\r\n    }\r\n    /**\r\n     * Retrieve collection all items count\r\n     *\r\n     * @return int\r\n     */\r\n    public function getSize()\r\n    {\r\n        if (is_null($this->_totalRecords)) {\r\n            $this->_totalRecords = count($this->getItems());\r\n        }\r\n        return intval($this->_totalRecords);\r\n    }\r\n    /**\r\n     * Retrieve collection items\r\n     *\r\n     * @return array\r\n     */\r\n    public function getItems()\r\n    {\r\n        return $this->_items;\r\n    }\r\n}"}}