Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

I would like to get all the product IDs from the current category page. I don't want to load the whole collection, I just need to get the product IDs from the products currently displayed.


E.g.:

  1. Customer goes on category, order is set to price descending, number of displayed products is set to 20 --> I just want to retrieve these product IDs

  2. Customer goes to page 2 --> now I just want to retrieve these product IDs

  3. Customer changes order to name asc, number of displayed products to 50 --> now I just want to retrieve these product IDs


So, getting the whole collection via

$category_id = Mage::getModel('catalog/layer')
     ->getCurrentCategory()
     ->getId();

$category = Mage::getModel('catalog/category')
     ->load($category_id);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addCategoryFilter($category)
    ->setOrder('price', 'ASC')
    ->load();

does not really help me, because I can't actually just the product IDs which are currently displayed to the customer. Is there some kind of way to filter and limit the collections to the values which the customer currently uses?


P.S: Get product id of current category pageGet product id of current category page this guy had the same question (I guess) but didn't receive any answer, at least none, that would help me with my problem.

I would like to get all the product IDs from the current category page. I don't want to load the whole collection, I just need to get the product IDs from the products currently displayed.


E.g.:

  1. Customer goes on category, order is set to price descending, number of displayed products is set to 20 --> I just want to retrieve these product IDs

  2. Customer goes to page 2 --> now I just want to retrieve these product IDs

  3. Customer changes order to name asc, number of displayed products to 50 --> now I just want to retrieve these product IDs


So, getting the whole collection via

$category_id = Mage::getModel('catalog/layer')
     ->getCurrentCategory()
     ->getId();

$category = Mage::getModel('catalog/category')
     ->load($category_id);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addCategoryFilter($category)
    ->setOrder('price', 'ASC')
    ->load();

does not really help me, because I can't actually just the product IDs which are currently displayed to the customer. Is there some kind of way to filter and limit the collections to the values which the customer currently uses?


P.S: Get product id of current category page this guy had the same question (I guess) but didn't receive any answer, at least none, that would help me with my problem.

I would like to get all the product IDs from the current category page. I don't want to load the whole collection, I just need to get the product IDs from the products currently displayed.


E.g.:

  1. Customer goes on category, order is set to price descending, number of displayed products is set to 20 --> I just want to retrieve these product IDs

  2. Customer goes to page 2 --> now I just want to retrieve these product IDs

  3. Customer changes order to name asc, number of displayed products to 50 --> now I just want to retrieve these product IDs


So, getting the whole collection via

$category_id = Mage::getModel('catalog/layer')
     ->getCurrentCategory()
     ->getId();

$category = Mage::getModel('catalog/category')
     ->load($category_id);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addCategoryFilter($category)
    ->setOrder('price', 'ASC')
    ->load();

does not really help me, because I can't actually just the product IDs which are currently displayed to the customer. Is there some kind of way to filter and limit the collections to the values which the customer currently uses?


P.S: Get product id of current category page this guy had the same question (I guess) but didn't receive any answer, at least none, that would help me with my problem.

Source Link
juhanix
  • 671
  • 6
  • 17

Get product IDs of current category page

I would like to get all the product IDs from the current category page. I don't want to load the whole collection, I just need to get the product IDs from the products currently displayed.


E.g.:

  1. Customer goes on category, order is set to price descending, number of displayed products is set to 20 --> I just want to retrieve these product IDs

  2. Customer goes to page 2 --> now I just want to retrieve these product IDs

  3. Customer changes order to name asc, number of displayed products to 50 --> now I just want to retrieve these product IDs


So, getting the whole collection via

$category_id = Mage::getModel('catalog/layer')
     ->getCurrentCategory()
     ->getId();

$category = Mage::getModel('catalog/category')
     ->load($category_id);

$products = Mage::getModel('catalog/product')
    ->getCollection()
    ->addAttributeToSelect('*')
    ->addCategoryFilter($category)
    ->setOrder('price', 'ASC')
    ->load();

does not really help me, because I can't actually just the product IDs which are currently displayed to the customer. Is there some kind of way to filter and limit the collections to the values which the customer currently uses?


P.S: Get product id of current category page this guy had the same question (I guess) but didn't receive any answer, at least none, that would help me with my problem.