0

for example my store has 20 products. I load all products using following code

$collection = Mage::getSingleton('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToSort('name','ASC');

In ascending order they list a product from number 1,2,3,...20.

how i get products which are numbered 8,9,10..15.

2

2 Answers 2

2

Try:

/** @var Mage_Catalog_Model_Resource_Product_Collection $collection */
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*')
    ->addAttributeToSort('name','ASC');
$collection->getSelect()->limit(8,7);
$items = $collection->getItems();
echo count($items); // or something else
1

this will do trick for you

$collection = Mage::getSingleton('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToSort('name','ASC')
$collection->getSelect()->limit(7,8);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.