[Skip to main content](#vessel-content)

#   Getting all Products in a Category

##

- **[philipp](/forum/user/35353-philipp "View philipp's Profile")**
- [![philipp's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35353-philipp "View philipp's Profile") Topic Author
- [ Offline](/forum/user/35353-philipp)

Less More

- Posts: 10
- Thank you received: 0
-
-

11 years 9 months ago [\#185615](#185615) by [philipp](/forum/user/35353-philipp "View philipp's Profile")  *[Getting all Products in a Category](/forum/31-development/874079-getting-all-products-in-a-category#185615 "-- HikaShop version -- : latest -- Joomla version -- : latest -- PHP version -- : latest -- Browser(s) name and version -- : ff latest  Hello Everybody,  Given a category ID, how can I get all the products in it?  I have tried this:  None of the methods returns the list of products or their ids…  How can I do that?")* was created by *[philipp](/forum/user/35353-philipp "View philipp's Profile")*

-- HikaShop version -- : latest
-- Joomla version -- : latest
-- PHP version -- : latest
-- Browser(s) name and version -- : ff latest

Hello Everybody,

Given a category ID, how can I get all the products in it?

I have tried this:
Code:

$category = hikashop_get('class.category'); //1. $category-&gt;get(&lt;cid&gt;); //2. $category-&gt;getProductsIn(&lt;cid&gt;, array(&lt;product&gt;)); //3. $category-&gt;getChildren(…)

None of the methods returns the list of products or their ids…

How can I do that?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3NDA3OS1nZXR0aW5nLWFsbC1wcm9kdWN0cy1pbi1hLWNhdGVnb3J5P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86290
- Thank you received: 14266
-
-

11 years 9 months ago [\#185634](#185634) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Getting all Products in a Category](/forum/31-development/874079-getting-all-products-in-a-category#185634 "-- HikaShop version -- : latest -- Joomla version -- : latest -- PHP version -- : latest -- Browser(s) name and version -- : ff latest  Hello Everybody,  Given a category ID, how can I get all the products in it?  I have tried this:  None of the methods returns the list of products or their ids…  How can I do that?")*

Hi,

There is no function to do that.
The best is to write a MySQL query and load the data yourself from the tables hikashop_product_category and hikashop_product.
Otherwise, you can use that code: Code:

$productClass = hikashop_get('class.product'); $productClass-&gt;getProducts(); $categoryClass = hikashop_get('class.category'); $products_in_the_category = $category-&gt;getProductsIn($category_id, $productClass-&gt;products);

But I don't recommend that as it first loads all the data of all the products in the getProducts() function (which is used for products exports) before loading the products based on the category id and these products list.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50Lzg3NDA3OS1nZXR0aW5nLWFsbC1wcm9kdWN0cy1pbi1hLWNhdGVnb3J5P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.111 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
