Pascal
Pascal

Reputation: 153

How to get all IDs of products fpr current page in magento

I encounter a huge problem with retrieving Product IDs for current page.

Current page is /catalog/product/list

and all data is taken with class

Mage_Catalog_Block_Product_List

There is method

$this->getLoadedProductCollection();

with the help of it all product items is returned as a collection

Is there any way to get only IDs of Products?

I need in it because I want to make some remote request with IDs array for getting some additional values before retrieving all data by $this->getLoadedProductCollection(); ??

Because doing 2 foreach is not a good idea.

foreach ($_productCollection as $_product) { $arrIds[] = $_product->getId(); }

foreach ($_productCollection as $_product) { show all products here }

Thanks

Upvotes: 1

Views: 3152

Answers (1)

user3816951
user3816951

Reputation: 21

in magento you have the $collection->getAllIds() method

Upvotes: 2

Related Questions