Grid pagination does not work in magento
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Pagination is not working in my grid. All records are being shown on same page.
All though Pagination is being shown at the top but all pages shows same records.
Here is the code--
protected function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$query="SELECT `e`.*,
`at_status`.`value` AS `status`,
`at_name`.`value` AS `name`,
`at_taq`.`value` AS `total_available_qty`,
`at_price`.`value` AS `price`,
`at_notify_stock_qty`.`notify_stock_qty`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_int` AS `at_status`
ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '273') AND (`at_status`.`store_id` = 0)
INNER JOIN `catalog_product_entity_varchar` AS `at_name`
ON (`at_name`.`entity_id` = `e`.`entity_id`) AND
(`at_name`.`attribute_id` = '96')
INNER JOIN `catalog_product_entity_varchar` AS `at_taq`
ON (`at_taq`.`entity_id` = `e`.`entity_id`) AND
(`at_taq`.`attribute_id` = '987')
INNER JOIN `catalog_product_entity_decimal` AS `at_price`
ON (`at_price`.`entity_id` = `e`.`entity_id`) AND
(`at_price`.`attribute_id` = '99')
INNER JOIN `cataloginventory_stock_item` AS `at_notify_stock_qty`
ON (at_notify_stock_qty.`product_id`=e.entity_id) AND
(at_notify_stock_qty.stock_id=1) WHERE (at_status.value = '1') AND (at_notify_stock_qty.notify_stock_qty > at_taq.value)";
$connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
$collection2=$connectionRead->fetchAll($query);
$collection = new Varien_Data_Collection();
foreach ($collection2 as $item) {
$varienObject = new Varien_Object();
$varienObject->setData($item);
$collection->addItem($varienObject);
}
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
Can any one help me what I am doing wrong ?
Solution--
I think the main problem was in collection which is mase by custom mysql query, so Now I used below code that worked fine--
$collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('status',1)
->addAttributeToSelect('total_available_qty')
->addFieldToFilter('total_available_qty',array('gteq'=>0))
->addAttributeToSelect('*')
->joinField('notify_stock_qty',
'cataloginventory/stock_item',
'notify_stock_qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
$collection ->getSelect()->where('`at_notify_stock_qty`.`notify_stock_qty` > `at_total_available_qty`.`value`');
magento-1 collection grid
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Pagination is not working in my grid. All records are being shown on same page.
All though Pagination is being shown at the top but all pages shows same records.
Here is the code--
protected function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$query="SELECT `e`.*,
`at_status`.`value` AS `status`,
`at_name`.`value` AS `name`,
`at_taq`.`value` AS `total_available_qty`,
`at_price`.`value` AS `price`,
`at_notify_stock_qty`.`notify_stock_qty`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_int` AS `at_status`
ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '273') AND (`at_status`.`store_id` = 0)
INNER JOIN `catalog_product_entity_varchar` AS `at_name`
ON (`at_name`.`entity_id` = `e`.`entity_id`) AND
(`at_name`.`attribute_id` = '96')
INNER JOIN `catalog_product_entity_varchar` AS `at_taq`
ON (`at_taq`.`entity_id` = `e`.`entity_id`) AND
(`at_taq`.`attribute_id` = '987')
INNER JOIN `catalog_product_entity_decimal` AS `at_price`
ON (`at_price`.`entity_id` = `e`.`entity_id`) AND
(`at_price`.`attribute_id` = '99')
INNER JOIN `cataloginventory_stock_item` AS `at_notify_stock_qty`
ON (at_notify_stock_qty.`product_id`=e.entity_id) AND
(at_notify_stock_qty.stock_id=1) WHERE (at_status.value = '1') AND (at_notify_stock_qty.notify_stock_qty > at_taq.value)";
$connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
$collection2=$connectionRead->fetchAll($query);
$collection = new Varien_Data_Collection();
foreach ($collection2 as $item) {
$varienObject = new Varien_Object();
$varienObject->setData($item);
$collection->addItem($varienObject);
}
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
Can any one help me what I am doing wrong ?
Solution--
I think the main problem was in collection which is mase by custom mysql query, so Now I used below code that worked fine--
$collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('status',1)
->addAttributeToSelect('total_available_qty')
->addFieldToFilter('total_available_qty',array('gteq'=>0))
->addAttributeToSelect('*')
->joinField('notify_stock_qty',
'cataloginventory/stock_item',
'notify_stock_qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
$collection ->getSelect()->where('`at_notify_stock_qty`.`notify_stock_qty` > `at_total_available_qty`.`value`');
magento-1 collection grid
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Pagination is not working in my grid. All records are being shown on same page.
All though Pagination is being shown at the top but all pages shows same records.
Here is the code--
protected function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$query="SELECT `e`.*,
`at_status`.`value` AS `status`,
`at_name`.`value` AS `name`,
`at_taq`.`value` AS `total_available_qty`,
`at_price`.`value` AS `price`,
`at_notify_stock_qty`.`notify_stock_qty`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_int` AS `at_status`
ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '273') AND (`at_status`.`store_id` = 0)
INNER JOIN `catalog_product_entity_varchar` AS `at_name`
ON (`at_name`.`entity_id` = `e`.`entity_id`) AND
(`at_name`.`attribute_id` = '96')
INNER JOIN `catalog_product_entity_varchar` AS `at_taq`
ON (`at_taq`.`entity_id` = `e`.`entity_id`) AND
(`at_taq`.`attribute_id` = '987')
INNER JOIN `catalog_product_entity_decimal` AS `at_price`
ON (`at_price`.`entity_id` = `e`.`entity_id`) AND
(`at_price`.`attribute_id` = '99')
INNER JOIN `cataloginventory_stock_item` AS `at_notify_stock_qty`
ON (at_notify_stock_qty.`product_id`=e.entity_id) AND
(at_notify_stock_qty.stock_id=1) WHERE (at_status.value = '1') AND (at_notify_stock_qty.notify_stock_qty > at_taq.value)";
$connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
$collection2=$connectionRead->fetchAll($query);
$collection = new Varien_Data_Collection();
foreach ($collection2 as $item) {
$varienObject = new Varien_Object();
$varienObject->setData($item);
$collection->addItem($varienObject);
}
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
Can any one help me what I am doing wrong ?
Solution--
I think the main problem was in collection which is mase by custom mysql query, so Now I used below code that worked fine--
$collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('status',1)
->addAttributeToSelect('total_available_qty')
->addFieldToFilter('total_available_qty',array('gteq'=>0))
->addAttributeToSelect('*')
->joinField('notify_stock_qty',
'cataloginventory/stock_item',
'notify_stock_qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
$collection ->getSelect()->where('`at_notify_stock_qty`.`notify_stock_qty` > `at_total_available_qty`.`value`');
magento-1 collection grid
Pagination is not working in my grid. All records are being shown on same page.
All though Pagination is being shown at the top but all pages shows same records.
Here is the code--
protected function _prepareCollection()
{
if ($this->getRequest()->getParam('website')) {
$storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('group')) {
$storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
$storeId = array_pop($storeIds);
} else if ($this->getRequest()->getParam('store')) {
$storeId = (int)$this->getRequest()->getParam('store');
} else {
$storeId = '';
}
$query="SELECT `e`.*,
`at_status`.`value` AS `status`,
`at_name`.`value` AS `name`,
`at_taq`.`value` AS `total_available_qty`,
`at_price`.`value` AS `price`,
`at_notify_stock_qty`.`notify_stock_qty`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_int` AS `at_status`
ON (`at_status`.`entity_id` = `e`.`entity_id`) AND (`at_status`.`attribute_id` = '273') AND (`at_status`.`store_id` = 0)
INNER JOIN `catalog_product_entity_varchar` AS `at_name`
ON (`at_name`.`entity_id` = `e`.`entity_id`) AND
(`at_name`.`attribute_id` = '96')
INNER JOIN `catalog_product_entity_varchar` AS `at_taq`
ON (`at_taq`.`entity_id` = `e`.`entity_id`) AND
(`at_taq`.`attribute_id` = '987')
INNER JOIN `catalog_product_entity_decimal` AS `at_price`
ON (`at_price`.`entity_id` = `e`.`entity_id`) AND
(`at_price`.`attribute_id` = '99')
INNER JOIN `cataloginventory_stock_item` AS `at_notify_stock_qty`
ON (at_notify_stock_qty.`product_id`=e.entity_id) AND
(at_notify_stock_qty.stock_id=1) WHERE (at_status.value = '1') AND (at_notify_stock_qty.notify_stock_qty > at_taq.value)";
$connectionRead = Mage::getSingleton('core/resource')->getConnection('core_read');
$collection2=$connectionRead->fetchAll($query);
$collection = new Varien_Data_Collection();
foreach ($collection2 as $item) {
$varienObject = new Varien_Object();
$varienObject->setData($item);
$collection->addItem($varienObject);
}
if( $storeId ) {
$collection->addStoreFilter($storeId);
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
Can any one help me what I am doing wrong ?
Solution--
I think the main problem was in collection which is mase by custom mysql query, so Now I used below code that worked fine--
$collection = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('status',1)
->addAttributeToSelect('total_available_qty')
->addFieldToFilter('total_available_qty',array('gteq'=>0))
->addAttributeToSelect('*')
->joinField('notify_stock_qty',
'cataloginventory/stock_item',
'notify_stock_qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left');
$collection ->getSelect()->where('`at_notify_stock_qty`.`notify_stock_qty` > `at_total_available_qty`.`value`');
magento-1 collection grid
magento-1 collection grid
edited May 7 '17 at 9:31
Siarhey Uchukhlebau
10.2k93058
10.2k93058
asked Jan 14 '16 at 5:50
Shashank KumrawatShashank Kumrawat
1,3211343
1,3211343
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The problem is the following:
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).
I suggest you look at the following resources to fix your problem:
- https://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working
- https://stackoverflow.com/questions/8937714/magento-custom-collection-breaks-pagination
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f97151%2fgrid-pagination-does-not-work-in-magento%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is the following:
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).
I suggest you look at the following resources to fix your problem:
- https://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working
- https://stackoverflow.com/questions/8937714/magento-custom-collection-breaks-pagination
add a comment |
The problem is the following:
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).
I suggest you look at the following resources to fix your problem:
- https://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working
- https://stackoverflow.com/questions/8937714/magento-custom-collection-breaks-pagination
add a comment |
The problem is the following:
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).
I suggest you look at the following resources to fix your problem:
- https://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working
- https://stackoverflow.com/questions/8937714/magento-custom-collection-breaks-pagination
The problem is the following:
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).
I suggest you look at the following resources to fix your problem:
- https://stackoverflow.com/questions/20197518/varien-data-collection-pagination-not-working
- https://stackoverflow.com/questions/8937714/magento-custom-collection-breaks-pagination
edited May 23 '17 at 12:37
Community♦
1
1
answered Jan 14 '16 at 8:30
Raphael at Digital PianismRaphael at Digital Pianism
55.4k22125283
55.4k22125283
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f97151%2fgrid-pagination-does-not-work-in-magento%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown